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;
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){
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'){
184 var feedback = this.el.select('.form-control-feedback', true).first();
187 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
195 this.fireEvent('valid', this);
199 * Mark this field as valid
201 markValid : function()
203 if(!this.el || this.preventMark){ // not rendered
207 this.el.removeClass([this.invalidClass, this.validClass]);
208 this.inputEl().removeClass(['is-valid', 'is-invalid']);
210 var feedback = this.el.select('.form-control-feedback', true).first();
213 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
218 if(this.disabled || this.allowBlank){
222 var label = this.el.select('label', true).first();
223 var icon = this.el.select('i.fa-star', true).first();
228 if (Roo.bootstrap.version == 3) {
229 this.el.addClass(this.validClass);
231 this.inputEl().addClass('is-valid');
235 if(this.hasFeedback && this.inputType != 'hidden'){
237 var feedback = this.el.select('.form-control-feedback', true).first();
240 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
241 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
246 this.fireEvent('valid', this);
250 * Mark this field as invalid
251 * @param {String} msg The validation message
253 markInvalid : function(msg)
255 if(!this.el || this.preventMark){ // not rendered
259 this.el.removeClass([this.invalidClass, this.validClass]);
260 this.inputEl().removeClass(['is-valid', 'is-invalid']);
262 var feedback = this.el.select('.form-control-feedback', true).first();
265 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
274 var label = this.el.select('label', true).first();
275 //var icon = this.el.select('i.fa-star', true).first();
277 //if(!this.getValue().length && label && !icon){
278 /* this.el.createChild({
280 cls : 'text-danger fa fa-lg fa-star',
281 tooltip : 'This field is required',
282 style : 'margin-right:5px;'
287 if (Roo.bootstrap.version == 3) {
288 this.el.addClass(this.invalidClass);
290 this.inputEl().addClass('is-invalid');
293 // fixme ... this may be depricated need to test..
294 if(this.hasFeedback && this.inputType != 'hidden'){
296 var feedback = this.el.select('.form-control-feedback', true).first();
299 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
301 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
303 feedback.update(this.invalidText);
305 if(!this.allowBlank && !this.getRawValue().length){
306 feedback.update(this.blankText);
309 if(feedback.dom.innerHTML) {
317 this.fireEvent('invalid', this, msg);