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-danger fa fa-lg fa-exclamation-triangle"
18 * @cfg {String} validClass default "text-success fa fa-lg fa-check"
19 * @cfg {String} iconTooltip default "This field is required"
22 * Create a new FieldLabel
23 * @param {Object} config The config object
26 Roo.bootstrap.FieldLabel = function(config){
27 Roo.bootstrap.Element.superclass.constructor.call(this, config);
32 * Fires after the field has been marked as invalid.
33 * @param {Roo.form.FieldLabel} this
34 * @param {String} msg The validation message
39 * Fires after the field has been validated with no errors.
40 * @param {Roo.form.FieldLabel} this
46 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
53 invalidClass : 'text-danger fa fa-lg fa-exclamation-triangle',
54 validClass : 'text-success fa fa-lg fa-check',
55 iconTooltip : 'This field is required',
57 getAutoCreate : function(){
61 cls : 'roo-bootstrap-field-label ' + this.cls,
67 tooltip : this.iconTooltip
79 initEvents: function()
81 Roo.bootstrap.Element.superclass.initEvents.call(this);
83 this.iconEl = this.el.select('i', true).first();
85 this.iconEl.setVisibilityMode(Roo.Element.DISPLAY).hide();
87 Roo.bootstrap.FieldLabel.register(this);
91 * Mark this field as valid
93 markValid : function()
97 this.iconEl.removeClass(this.invalidClass);
99 this.iconEl.addClass(this.validClass);
101 this.fireEvent('valid', this);
105 * Mark this field as invalid
106 * @param {String} msg The validation message
108 markInvalid : function(msg)
112 this.iconEl.removeClass(this.validClass);
114 this.iconEl.addClass(this.invalidClass);
116 this.fireEvent('invalid', this, msg);
122 Roo.apply(Roo.bootstrap.FieldLabel, {
127 * register a FieldLabel Group
128 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
130 register : function(label)
132 if(this.groups.hasOwnProperty(label.for)){
136 this.groups[label.for] = label;
140 * fetch a FieldLabel Group based on the for
141 * @param {string} for
142 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
144 get: function(name) {
145 if (typeof(this.groups[name]) == 'undefined') {
149 return this.groups[name] ;