var cfg = {};
+ if(this.inputType != 'hidden'){
+ cfg.cls = 'form-group' //input-group
+ }
+
var input = {
tag: 'textarea',
id : id,
}
if (align ==='left' && this.fieldLabel.length) {
- Roo.log("left and has label");
- cfg.cn = [
-
- {
- tag: 'label',
- 'for' : id,
- cls : 'control-label col-sm-' + this.labelWidth,
- html : this.fieldLabel
-
- },
- {
- cls : "col-sm-" + (12 - this.labelWidth),
- cn: [
- inputblock
- ]
- }
-
- ];
+ cfg.cn = [
+ {
+ tag: 'label',
+ 'for' : id,
+ cls : 'control-label',
+ html : this.fieldLabel
+ },
+ {
+ cls : "",
+ cn: [
+ inputblock
+ ]
+ }
+
+ ];
+
+ if(this.labelWidth > 12){
+ cfg.cn[0].style = "width: " + this.labelWidth + 'px';
+ }
+
+ if(this.labelWidth < 13 && this.labelmd == 0){
+ this.labelmd = this.labelWidth;
+ }
+
+ if(this.labellg > 0){
+ cfg.cn[0].cls += ' col-lg-' + this.labellg;
+ cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
+ }
+
+ if(this.labelmd > 0){
+ cfg.cn[0].cls += ' col-md-' + this.labelmd;
+ cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
+ }
+
+ if(this.labelsm > 0){
+ cfg.cn[0].cls += ' col-sm-' + this.labelsm;
+ cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
+ }
+
+ if(this.labelxs > 0){
+ cfg.cn[0].cls += ' col-xs-' + this.labelxs;
+ cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
+ }
+
} else if ( this.fieldLabel.length) {
- Roo.log(" label");
- cfg.cn = [
-
- {
- tag: 'label',
- //cls : 'input-group-addon',
- html : this.fieldLabel
-
- },
-
- inputblock
-
- ];
+ cfg.cn = [
+
+ {
+ tag: 'label',
+ //cls : 'input-group-addon',
+ html : this.fieldLabel
+
+ },
+
+ inputblock
+
+ ];
} else {
-
- Roo.log(" no label && no align");
- cfg.cn = [
-
- inputblock
-
- ];
-
+
+ cfg.cn = [
+
+ inputblock
+
+ ];
}
},
/**
- * Mark this field as valid
+ * Clear any invalid styles/messages for this field
*/
- markValid : function()
+ clearInvalid : function()
{
- if(this.allowBlank || this.disabled){
+
+ if(!this.el || this.preventMark){ // not rendered
return;
}
- var _this = this;
+ var label = this.el.select('label', true).first();
+ var icon = this.el.select('i.fa-star', true).first();
- this.fireEvent('valid', this);
+ if(label && icon){
+ icon.remove();
+ }
- var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
+ this.el.removeClass([ this.invalidClass, 'is-invalid']);
- if(this.groupId){
- label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
+ if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
+
+ var feedback = this.el.select('.form-control-feedback', true).first();
+
+ if(feedback){
+ this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
+ }
+
}
- if(label){
- label.markValid();
+ this.fireEvent('valid', this);
+ },
+
+ /**
+ * Mark this field as valid
+ */
+ markValid : function()
+ {
+ if(!this.el || this.preventMark){ // not rendered
+ return;
}
- if(this.inputType == 'radio'){
- Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
- e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
- e.findParent('.form-group', false, true).addClass(_this.validClass);
- });
+ this.el.removeClass([this.invalidClass, this.validClass]);
+
+ var feedback = this.el.select('.form-control-feedback', true).first();
+ if(feedback){
+ this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
+ }
+
+ if(this.disabled || this.allowBlank){
return;
}
- if(!this.groupId){
- this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
- this.el.findParent('.form-group', false, true).addClass(this.validClass);
- return;
+ var label = this.el.select('label', true).first();
+ var icon = this.el.select('i.fa-star', true).first();
+
+ if(label && icon){
+ icon.remove();
}
- var group = Roo.bootstrap.CheckBox.get(this.groupId);
+ this.el.addClass(this.validClass);
+
+ if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
+
+ var feedback = this.el.select('.form-control-feedback', true).first();
+
+ if(feedback){
+ this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
+ this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
+ }
- if(!group){
- return;
}
- for(var i in group){
- group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
- group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
- }
+ this.fireEvent('valid', this);
},
/**
*/
markInvalid : function(msg)
{
- if(this.allowBlank || this.disabled){
+ if(!this.el || this.preventMark){ // not rendered
return;
}
- var _this = this;
+ this.el.removeClass([this.invalidClass, this.validClass]);
- this.fireEvent('invalid', this, msg);
-
- var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
-
- if(this.groupId){
- label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
- }
-
- if(label){
- label.markInvalid();
- }
-
- if(this.inputType == 'radio'){
- Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
- e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
- e.findParent('.form-group', false, true).addClass(_this.invalidClass);
- });
+ var feedback = this.el.select('.form-control-feedback', true).first();
- return;
+ if(feedback){
+ this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
}
-
- if(!this.groupId){
- this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
- this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
+
+ if(this.disabled || this.allowBlank){
return;
}
- var group = Roo.bootstrap.CheckBox.get(this.groupId);
+ var label = this.el.select('label', true).first();
+ var icon = this.el.select('i.fa-star', true).first();
- if(!group){
- return;
+ if(!this.getValue().length && label && !icon){
+ this.el.createChild({
+ tag : 'i',
+ cls : 'text-danger fa fa-lg fa-star',
+ tooltip : 'This field is required',
+ style : 'margin-right:5px;'
+ }, label, true);
}
+
+ this.el.addClass(this.invalidClass);
- for(var i in group){
- group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
- group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
+ if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
+
+ var feedback = this.el.select('.form-control-feedback', true).first();
+
+ if(feedback){
+ this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
+
+ if(this.getValue().length || this.forceFeedback){
+ this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
+ }
+
+ }
+
}
+ this.fireEvent('invalid', this, msg);
}
});