10 <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
11 Option one is this and that—be sure to include why it's great
18 *<label class="radio-inline">fieldLabel</label>
19 *<label class="radio-inline">
20 <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1"> 1
28 * @class Roo.bootstrap.Radio
29 * @extends Roo.bootstrap.CheckBox
30 * Bootstrap Radio class
34 * @param {Object} config The config object
37 Roo.bootstrap.Radio = function(config){
38 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
42 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.CheckBox, {
48 getAutoCreate : function()
50 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
51 align = align || 'left'; // default...
58 tag : this.inline ? 'span' : 'div',
63 var inline = this.inline ? ' radio-inline' : '';
67 // does not need for, as we wrap the input with it..
69 cls : 'control-label box-label' + inline,
72 var labelWidth = this.labelWidth ? this.labelWidth *1 : 100;
76 //cls : 'control-label' + inline,
77 html : this.fieldLabel,
78 style : 'width:' + labelWidth + 'px;line-height:1;vertical-align:bottom;' // should be css really.
87 type : this.inputType,
88 //value : (!this.checked) ? this.valueOff : this.inputValue,
89 value : this.inputValue,
91 placeholder : this.placeholder || '' // ?? needed????
94 if (this.weight) { // Validity check?
95 input.cls += " radio-" + this.weight;
102 input.checked = this.checked;
106 input.name = this.name;
110 input.cls += ' input-' + this.size;
113 //?? can span's inline have a width??
116 ['xs','sm','md','lg'].map(function(size){
117 if (settings[size]) {
118 cfg.cls += ' col-' + size + '-' + settings[size];
122 var inputblock = input;
124 if (this.before || this.after) {
134 cls : 'input-group-addon',
138 inputblock.cn.push(input);
142 cls : 'input-group-addon',
150 if (this.fieldLabel && this.fieldLabel.length) {
151 cfg.cn.push(fieldLabel);
154 // normal bootstrap puts the input inside the label.
155 // however with our styled version - it has to go after the input.
157 //lbl.cn.push(inputblock);
161 cls: 'radio' + inline,
168 cfg.cn.push( lblwrap);
182 initEvents : function()
184 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
186 this.inputEl().on('click', this.onClick, this);
188 Roo.log('find label')
189 this.el.select('span.radio label span',true).first().on('click', this.onClick, this);
196 return this.el.select('input.roo-radio',true).first();
201 this.setChecked(true);
204 setChecked : function(state,suppressEvent)
207 Roo.each(this.inputEl().up('form').select('input[name='+this.inputEl().dom.name+']', true).elements, function(v){
208 v.dom.checked = false;
211 Roo.log(this.inputEl().dom);
212 this.checked = state;
213 this.inputEl().dom.checked = state;
215 if(suppressEvent !== true){
216 this.fireEvent('check', this, state);
219 //this.inputEl().dom.value = state ? this.inputValue : this.valueOff;
223 getGroupValue : function()
226 Roo.each(this.inputEl().up('form').select('input[name='+this.inputEl().dom.name+']', true).elements, function(v){
227 if(v.dom.checked == true){
236 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
237 * @return {Mixed} value The field value
239 getValue : function(){
240 return this.getGroupValue();