9 * @class Roo.bootstrap.TextArea
10 * @extends Roo.bootstrap.Input
11 * Bootstrap TextArea class
12 * @cfg {Number} cols Specifies the visible width of a text area
13 * @cfg {Number} rows Specifies the visible number of lines in a text area
14 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
15 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
16 * @cfg {string} html text
19 * Create a new TextArea
20 * @param {Object} config The config object
23 Roo.bootstrap.TextArea = function(config){
24 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
28 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
38 getAutoCreate : function(){
40 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
51 value : this.value || '',
52 html: this.html || '',
54 placeholder : this.placeholder || ''
58 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
59 input.maxLength = this.maxLength;
63 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
67 input.cols = this.cols;
71 input.readonly = true;
75 input.name = this.name;
79 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
83 ['xs','sm','md','lg'].map(function(size){
85 cfg.cls += ' col-' + size + '-' + settings[size];
89 var inputblock = input;
91 if(this.hasFeedback && !this.allowBlank){
95 cls: 'glyphicon form-control-feedback'
108 if (this.before || this.after) {
117 cls : 'input-group-addon',
122 inputblock.cn.push(input);
124 if(this.hasFeedback && !this.allowBlank){
125 inputblock.cls += ' has-feedback';
126 inputblock.cn.push(feedback);
132 cls : 'input-group-addon',
139 if (align ==='left' && this.fieldLabel.length) {
145 cls : 'control-label col-sm-' + this.labelWidth,
146 html : this.fieldLabel
150 cls : "col-sm-" + (12 - this.labelWidth),
157 } else if ( this.fieldLabel.length) {
162 //cls : 'input-group-addon',
163 html : this.fieldLabel
189 * return the real textarea element.
193 return this.el.select('textarea.form-control',true).first();
197 * Clear any invalid styles/messages for this field
199 clearInvalid : function()
202 if(!this.el || this.preventMark){ // not rendered
206 var label = this.el.select('label', true).first();
207 var icon = this.el.select('i.fa-star', true).first();
213 this.el.removeClass(this.invalidClass);
215 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
217 var feedback = this.el.select('.form-control-feedback', true).first();
220 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
225 this.fireEvent('valid', this);
229 * Mark this field as valid
231 markValid : function()
233 if(!this.el || this.preventMark){ // not rendered
237 this.el.removeClass([this.invalidClass, this.validClass]);
239 var feedback = this.el.select('.form-control-feedback', true).first();
242 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
245 if(this.disabled || this.allowBlank){
249 var label = this.el.select('label', true).first();
250 var icon = this.el.select('i.fa-star', true).first();
256 this.el.addClass(this.validClass);
258 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
260 var feedback = this.el.select('.form-control-feedback', true).first();
263 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
264 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
269 this.fireEvent('valid', this);
273 * Mark this field as invalid
274 * @param {String} msg The validation message
276 markInvalid : function(msg)
278 if(!this.el || this.preventMark){ // not rendered
282 this.el.removeClass([this.invalidClass, this.validClass]);
284 var feedback = this.el.select('.form-control-feedback', true).first();
287 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
290 if(this.disabled || this.allowBlank){
294 var label = this.el.select('label', true).first();
295 var icon = this.el.select('i.fa-star', true).first();
297 if(!this.getValue().length && label && !icon){
298 this.el.createChild({
300 cls : 'text-danger fa fa-lg fa-star',
301 tooltip : 'This field is required',
302 style : 'margin-right:5px;'
306 this.el.addClass(this.invalidClass);
308 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
310 var feedback = this.el.select('.form-control-feedback', true).first();
313 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
315 if(this.getValue().length || this.forceFeedback){
316 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
323 this.fireEvent('invalid', this, msg);