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} for 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"
21 * Create a new FieldLabel
22 * @param {Object} config The config object
25 Roo.bootstrap.FieldLabel = function(config){
26 Roo.bootstrap.Element.superclass.constructor.call(this, config);
31 * Fires after the field has been marked as invalid.
32 * @param {Roo.form.FieldLabel} this
33 * @param {String} msg The validation message
38 * Fires after the field has been validated with no errors.
39 * @param {Roo.form.FieldLabel} this
45 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
52 invalidClass : 'text-danger fa fa-lg fa-exclamation-triangle',
53 validClass : 'text-success fa fa-lg fa-check',
55 getAutoCreate : function(){
59 cls : 'roo-bootstrap-field-label ' + this.cls,
76 initEvents: function()
78 Roo.bootstrap.Element.superclass.initEvents.call(this);
80 this.iconEl = this.el.select('i', true).first();
82 this.iconEl.setVisibilityMode(Roo.Element.DISPLAY).hide();
84 Roo.bootstrap.FieldLabel.register(this);
89 * Mark this field as valid
91 markValid : function()
95 this.iconEl.removeClass(this.invalidClass);
97 this.iconEl.addClass(this.validClass);
99 this.fireEvent('valid', this);
103 * Mark this field as invalid
104 * @param {String} msg The validation message
106 markInvalid : function(msg)
110 this.iconEl.removeClass(this.validClass);
112 this.iconEl.addClass(this.invalidClass);
114 this.fireEvent('invalid', this, msg);
120 Roo.apply(Roo.bootstrap.FieldLabel, {
125 * register a FieldLabel Group
126 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
128 register : function(label)
130 if(typeof(this.groups[label.for]) == 'undefined'){
131 this.groups[label.for] = {};
133 Roo.log('register???!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
136 if(this.groups.hasOwnProperty(label.for)){
141 this.groups[label.for] = label;
145 * fetch a FieldLabel Group based on the for
146 * @param {string} for
147 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
149 get: function(name) {
150 if (typeof(this.groups[name]) == 'undefined') {
154 return this.groups[name] ;