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);
194 this.fireEvent('valid', this);
198 * Mark this field as valid
200 markValid : function()
202 if(!this.el || this.preventMark){ // not rendered
206 this.el.removeClass([this.invalidClass, this.validClass]);
207 this.inputEl().removeClass(['is-valid', 'is-invalid']);
209 var feedback = this.el.select('.form-control-feedback', true).first();
212 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
216 if(this.disabled || this.allowBlank){
220 var label = this.el.select('label', true).first();
221 var icon = this.el.select('i.fa-star', true).first();
226 if (Roo.bootstrap.version == 3) {
227 this.el.addClass(this.validClass);
229 this.inputEl().addClass('is-valid');
233 if(this.hasFeedback && this.inputType != 'hidden'){
235 var feedback = this.el.select('.form-control-feedback', true).first();
238 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
239 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
244 this.fireEvent('valid', this);
248 * Mark this field as invalid
249 * @param {String} msg The validation message
251 markInvalid : function(msg)
253 if(!this.el || this.preventMark){ // not rendered
257 this.el.removeClass([this.invalidClass, this.validClass]);
258 this.inputEl().removeClass(['is-valid', 'is-invalid']);
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]);
271 var label = this.el.select('label', true).first();
272 //var icon = this.el.select('i.fa-star', true).first();
274 //if(!this.getValue().length && label && !icon){
275 /* this.el.createChild({
277 cls : 'text-danger fa fa-lg fa-star',
278 tooltip : 'This field is required',
279 style : 'margin-right:5px;'
284 if (Roo.bootstrap.version == 3) {
285 this.el.addClass(this.invalidClass);
287 this.inputEl().addClass('is-invalid');
290 // fixme ... this may be depricated need to test..
291 if(this.hasFeedback && this.inputType != 'hidden'){
293 var feedback = this.el.select('.form-control-feedback', true).first();
296 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
298 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
300 feedback.update(this.invalidText);
302 if(!this.allowBlank && !this.getRawValue().length){
303 feedback.update(this.blankText);
310 this.fireEvent('invalid', this, msg);