9 * @class Roo.bootstrap.FieldLabel
10 * @extends Roo.bootstrap.Component
11 * Bootstrap FieldLabel class
12 * @cfg {String} html contents of the element
13 * @cfg {String} tag tag of the element default label
14 * @cfg {String} cls class of the element
15 * @cfg {String} target label target
16 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
17 * @cfg {String} invalidClass default "text-warning"
18 * @cfg {String} validClass default "text-success"
19 * @cfg {String} iconTooltip default "This field is required"
20 * @cfg {String} indicatorpos (left|right) default left
23 * Create a new FieldLabel
24 * @param {Object} config The config object
27 Roo.bootstrap.FieldLabel = function(config){
28 Roo.bootstrap.Element.superclass.constructor.call(this, config);
33 * Fires after the field has been marked as invalid.
34 * @param {Roo.form.FieldLabel} this
35 * @param {String} msg The validation message
40 * Fires after the field has been validated with no errors.
41 * @param {Roo.form.FieldLabel} this
47 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
54 invalidClass : 'has-warning',
55 validClass : 'has-success',
56 iconTooltip : 'This field is required',
57 indicatorpos : 'left',
59 getAutoCreate : function(){
63 if (!this.allowBlank) {
69 cls : 'roo-bootstrap-field-label ' + this.cls,
83 cls : 'roo-bootstrap-field-label ' + this.cls,
88 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
89 tooltip : this.iconTooltip
98 if(this.indicatorpos == 'right'){
101 cls : 'roo-bootstrap-field-label ' + this.cls,
110 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
111 tooltip : this.iconTooltip
121 initEvents: function()
123 Roo.bootstrap.Element.superclass.initEvents.call(this);
125 this.indicator = this.indicatorEl();
128 this.indicator.removeClass('visible');
129 this.indicator.addClass('invisible');
132 Roo.bootstrap.FieldLabel.register(this);
135 indicatorEl : function()
137 var indicator = this.el.select('i.roo-required-indicator',true).first();
148 * Mark this field as valid
150 markValid : function()
153 this.indicator.removeClass('visible');
154 this.indicator.addClass('invisible');
157 this.el.removeClass(this.invalidClass);
159 this.el.addClass(this.validClass);
161 this.fireEvent('valid', this);
165 * Mark this field as invalid
166 * @param {String} msg The validation message
168 markInvalid : function(msg)
171 this.indicator.removeClass('invisible');
172 this.indicator.addClass('visible');
175 this.el.removeClass(this.validClass);
177 this.el.addClass(this.invalidClass);
179 this.fireEvent('invalid', this, msg);
185 Roo.apply(Roo.bootstrap.FieldLabel, {
190 * register a FieldLabel Group
191 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
193 register : function(label)
195 if(this.groups.hasOwnProperty(label.target)){
199 this.groups[label.target] = label;
203 * fetch a FieldLabel Group based on the target
204 * @param {string} target
205 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
207 get: function(target) {
208 if (typeof(this.groups[target]) == 'undefined') {
212 return this.groups[target] ;