4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-form-RadioGroup'>/**
19 </span> * A {@link Ext.form.FieldContainer field container} which has a specialized layout for arranging
20 * {@link Ext.form.field.Radio} controls into columns, and provides convenience {@link Ext.form.field.Field}
21 * methods for {@link #getValue getting}, {@link #setValue setting}, and {@link #validate validating} the
22 * group of radio buttons as a whole.
26 * Individual radio buttons themselves have no default validation behavior, but
27 * sometimes you want to require a user to select one of a group of radios. RadioGroup
28 * allows this by setting the config `{@link #allowBlank}:false`; when the user does not check at
29 * one of the radio buttons, the entire group will be highlighted as invalid and the
30 * {@link #blankText error message} will be displayed according to the {@link #msgTarget} config.</p>
34 * The default layout for RadioGroup makes it easy to arrange the radio buttons into
35 * columns; see the {@link #columns} and {@link #vertical} config documentation for details. You may also
36 * use a completely different layout by setting the {@link #layout} to one of the other supported layout
37 * types; for instance you may wish to use a custom arrangement of hbox and vbox containers. In that case
38 * the Radio components at any depth will still be managed by the RadioGroup's validation.
43 * Ext.create('Ext.form.Panel', {
44 * title: 'RadioGroup Example',
48 * renderTo: Ext.getBody(),
50 * xtype: 'radiogroup',
51 * fieldLabel: 'Two Columns',
52 * // Arrange radio buttons into two columns, distributed vertically
56 * { boxLabel: 'Item 1', name: 'rb', inputValue: '1' },
57 * { boxLabel: 'Item 2', name: 'rb', inputValue: '2', checked: true},
58 * { boxLabel: 'Item 3', name: 'rb', inputValue: '3' },
59 * { boxLabel: 'Item 4', name: 'rb', inputValue: '4' },
60 * { boxLabel: 'Item 5', name: 'rb', inputValue: '5' },
61 * { boxLabel: 'Item 6', name: 'rb', inputValue: '6' }
67 Ext.define('Ext.form.RadioGroup', {
68 extend: 'Ext.form.CheckboxGroup',
69 alias: 'widget.radiogroup',
71 <span id='Ext-form-RadioGroup-cfg-items'> /**
72 </span> * @cfg {Ext.form.field.Radio[]/Object[]} items
73 * An Array of {@link Ext.form.field.Radio Radio}s or Radio config objects to arrange in the group.
75 <span id='Ext-form-RadioGroup-cfg-allowBlank'> /**
76 </span> * @cfg {Boolean} allowBlank True to allow every item in the group to be blank.
77 * If allowBlank = false and no items are selected at validation time, {@link #blankText} will
78 * be used as the error text.
81 <span id='Ext-form-RadioGroup-cfg-blankText'> /**
82 </span> * @cfg {String} blankText Error text to display if the {@link #allowBlank} validation fails
84 blankText : 'You must select one item in this group',
87 defaultType : 'radiofield',
90 groupCls : Ext.baseCSSPrefix + 'form-radio-group',
92 getBoxes: function() {
93 return this.query('[isRadio]');
96 <span id='Ext-form-RadioGroup-method-setValue'> /**
97 </span> * Sets the value of the radio group. The radio with corresponding name and value will be set.
98 * This method is simpler than {@link Ext.form.CheckboxGroup#setValue} because only 1 value is allowed
101 * @param {Object} value The map from names to values to be set.
102 * @return {Ext.form.CheckboxGroup} this
104 setValue: function(value) {
106 if (Ext.isObject(value)) {
107 Ext.Object.each(value, function(name, cbValue) {
108 var radios = Ext.form.RadioManager.getWithValue(name, cbValue);
109 radios.each(function(cb) {