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();
90 Roo.bootstrap.FieldLabel.register(this);
94 * Mark this field as valid
96 markValid : function()
100 this.iconEl.removeClass(this.invalidClass);
102 this.iconEl.addClass(this.validClass);
104 this.fireEvent('valid', this);
108 * Mark this field as invalid
109 * @param {String} msg The validation message
111 markInvalid : function(msg)
115 this.iconEl.removeClass(this.validClass);
117 this.iconEl.addClass(this.invalidClass);
119 this.fireEvent('invalid', this, msg);
125 Roo.apply(Roo.bootstrap.FieldLabel, {
130 * register a FieldLabel Group
131 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
133 register : function(label)
135 if(this.groups.hasOwnProperty(label.target)){
139 this.groups[label.target] = label;
143 * fetch a FieldLabel Group based on the target
144 * @param {string} target
145 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
147 get: function(target) {
148 if (typeof(this.groups[target]) == 'undefined') {
152 return this.groups[target] ;