9 * @class Roo.bootstrap.form.TextArea
10 * @extends Roo.bootstrap.form.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.form.TextArea = function(config){
24 Roo.bootstrap.form.TextArea.superclass.constructor.call(this, config);
28 Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, {
38 getAutoCreate : function(){
40 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
46 if(this.inputType != 'hidden'){
47 cfg.cls = 'form-group' //input-group
55 value : this.value || '',
56 html: this.html || '',
58 placeholder : this.placeholder || ''
62 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
63 input.maxLength = this.maxLength;
67 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
71 input.cols = this.cols;
75 input.readonly = true;
79 input.name = this.name;
83 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
87 ['xs','sm','md','lg'].map(function(size){
89 cfg.cls += ' col-' + size + '-' + settings[size];
93 var inputblock = input;
95 if(this.hasFeedback && !this.allowBlank){
99 cls: 'glyphicon form-control-feedback'
103 cls : 'has-feedback',
112 if (this.before || this.after) {
121 cls : 'input-group-addon',
126 inputblock.cn.push(input);
128 if(this.hasFeedback && !this.allowBlank){
129 inputblock.cls += ' has-feedback';
130 inputblock.cn.push(feedback);
136 cls : 'input-group-addon',
144 cfg = this.getAutoCreateLabel( cfg, inputblock );
156 * return the real textarea element.
160 return this.el.select('textarea.form-control',true).first();
164 * Clear any invalid styles/messages for this field
166 clearInvalid : function()
169 if(!this.el || this.preventMark){ // not rendered
173 var label = this.el.select('label', true).first();
174 var icon = this.el.select('i.fa-star', true).first();
179 this.el.removeClass( this.validClass);
180 this.inputEl().removeClass('is-invalid');
182 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
184 var feedback = this.el.select('.form-control-feedback', true).first();
187 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
192 this.fireEvent('valid', this);
196 * Mark this field as valid
198 markValid : function()
200 if(!this.el || this.preventMark){ // not rendered
204 this.el.removeClass([this.invalidClass, this.validClass]);
205 this.inputEl().removeClass(['is-valid', 'is-invalid']);
207 var feedback = this.el.select('.form-control-feedback', true).first();
210 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
213 if(this.disabled || this.allowBlank){
217 var label = this.el.select('label', true).first();
218 var icon = this.el.select('i.fa-star', true).first();
223 if (Roo.bootstrap.version == 3) {
224 this.el.addClass(this.validClass);
226 this.inputEl().addClass('is-valid');
230 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
232 var feedback = this.el.select('.form-control-feedback', true).first();
235 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
236 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
241 this.fireEvent('valid', this);
245 * Mark this field as invalid
246 * @param {String} msg The validation message
248 markInvalid : function(msg)
250 if(!this.el || this.preventMark){ // not rendered
254 this.el.removeClass([this.invalidClass, this.validClass]);
255 this.inputEl().removeClass(['is-valid', 'is-invalid']);
257 var feedback = this.el.select('.form-control-feedback', true).first();
260 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
263 if(this.disabled || this.allowBlank){
267 var label = this.el.select('label', true).first();
268 var icon = this.el.select('i.fa-star', true).first();
270 if(!this.getValue().length && label && !icon){
271 this.el.createChild({
273 cls : 'text-danger fa fa-lg fa-star',
274 tooltip : 'This field is required',
275 style : 'margin-right:5px;'
279 if (Roo.bootstrap.version == 3) {
280 this.el.addClass(this.invalidClass);
282 this.inputEl().addClass('is-invalid');
285 // fixme ... this may be depricated need to test..
286 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
288 var feedback = this.el.select('.form-control-feedback', true).first();
291 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
293 if(this.getValue().length || this.forceFeedback){
294 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
301 this.fireEvent('invalid', this, msg);