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.labelEl = this.el.select('.roo-radio-set-label', true).first();
126 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
128 if(!this.fieldLabel.length){
132 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
133 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
135 this.indicatorEl().hide();
137 this.originalValue = this.getValue();
143 return this.el.select('.roo-radio-set-input', true).first();
146 getChildContainer : function()
151 register : function(item)
153 this.radioes.push(item);
156 item.el.addClass('radio-inline');
161 validate : function()
165 Roo.each(this.radioes, function(i){
174 if(this.disabled || this.allowBlank || valid){
184 markValid : function()
186 if(this.labelEl.isVisible(true)){
187 this.indicatorEl().hide();
190 this.el.removeClass([this.invalidClass, this.validClass]);
191 this.el.addClass(this.validClass);
193 this.fireEvent('valid', this);
196 markInvalid : function(msg)
198 if(this.allowBlank || this.disabled){
202 if(this.labelEl.isVisible(true)){
203 this.indicatorEl().show();
206 this.el.removeClass([this.invalidClass, this.validClass]);
207 this.el.addClass(this.invalidClass);
209 this.fireEvent('invalid', this, msg);
213 setValue : function(v, suppressEvent)
215 Roo.each(this.radioes, function(i){
218 i.el.removeClass('checked');
220 if(i.value === v || i.value.toString() === v.toString()){
222 i.el.addClass('checked');
224 if(suppressEvent !== true){
225 this.fireEvent('check', this, i);
231 Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
237 Roo.apply(Roo.bootstrap.RadioSet, {
241 register : function(set)
243 this.groups[set.name] = set;
248 if (typeof(this.groups[name]) == 'undefined') {
252 return this.groups[name] ;