10 * @class Roo.bootstrap.RadioSet
11 * @extends Roo.bootstrap.Input
12 * Bootstrap RadioSet class
13 * @cfg {String} indicatorpos (left|right) default left
14 * @cfg {Boolean} inline (true|false) inline the element (default true)
15 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
17 * Create a new RadioSet
18 * @param {Object} config The config object
21 Roo.bootstrap.RadioSet = function(config){
23 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
27 Roo.bootstrap.RadioSet.register(this);
32 * Fires when the element is checked or unchecked.
33 * @param {Roo.bootstrap.RadioSet} this This radio
34 * @param {Roo.bootstrap.Radio} item The checked item
41 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
51 indicatorpos : 'left',
53 getAutoCreate : function()
57 cls : 'roo-radio-set-label',
61 html : this.fieldLabel
66 if(this.indicatorpos == 'left'){
69 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
70 tooltip : 'This field is required'
75 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
76 tooltip : 'This field is required'
82 cls : 'roo-radio-set-items'
85 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
87 if (align === 'left' && this.fieldLabel.length) {
89 label.cls += ' col-md-' + this.labelWidth;
92 cls : "col-md-" + (12 - this.labelWidth),
101 cls : 'roo-radio-set',
105 cls : 'roo-radio-set-input',
108 value : this.value ? this.value : ''
116 cfg.cls += ' roo-radio-set-inline';
123 initEvents : function()
125 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
126 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
128 this.indicatorEl().hide();
130 this.originalValue = this.getValue();
136 return this.el.select('.roo-radio-set-input', true).first();
139 getChildContainer : function()
144 register : function(item)
146 this.radioes.push(item);
149 item.el.addClass('radio-inline');
154 validate : function()
158 Roo.each(this.radioes, function(i){
167 if(this.disabled || this.allowBlank || valid){
177 markValid : function()
179 this.indicatorEl().hide();
180 this.el.removeClass([this.invalidClass, this.validClass]);
181 this.el.addClass(this.validClass);
183 this.fireEvent('valid', this);
186 markInvalid : function(msg)
188 if(this.allowBlank || this.disabled){
192 this.indicatorEl().show();
193 this.el.removeClass([this.invalidClass, this.validClass]);
194 this.el.addClass(this.invalidClass);
196 this.fireEvent('invalid', this, msg);
200 setValue : function(v, suppressEvent)
202 Roo.each(this.radioes, function(i){
205 i.el.removeClass('checked');
207 if(i.value === v || i.value === v.toString()){
209 i.el.addClass('checked');
211 if(suppressEvent !== true){
212 this.fireEvent('check', this, i);
218 Roo.bootstrap.RadioSet.superclass.setValue.call(this)
224 Roo.apply(Roo.bootstrap.RadioSet, {
228 register : function(set)
230 this.groups[set.name] = set;
235 if (typeof(this.groups[name]) == 'undefined') {
239 return this.groups[name] ;