Skip to content

Commit 0f3c40f

Browse files
committed
added textarea
1 parent 4a866fe commit 0f3c40f

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

src/fields/fieldTextarea.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import baseField from './baseField';
2+
export default {
3+
mixins: [baseField],
4+
render(h){
5+
const self = this;
6+
const children = [];
7+
8+
// add the label if it needs it
9+
if ( this.to.label ) children.push(
10+
h('label', {
11+
attrs: {
12+
'for': this.to.id
13+
}
14+
}, this.to.label )
15+
);
16+
17+
// add the textarea
18+
children.push(
19+
h('textarea', {
20+
attrs: {
21+
id: this.to.id,
22+
...this.to.atts
23+
},
24+
'class': {
25+
'form-control': true,
26+
...this.to.classes
27+
},
28+
domProps: {
29+
value: this.model[ this.field.key ]
30+
},
31+
on: {
32+
input(event){
33+
self.model[ self.field.key ] = event.target.value;
34+
self.$emit('input', event.target.value);
35+
},
36+
blur: this.onBlur,
37+
focus: this.onFocus,
38+
click: this.onClick,
39+
change: this.onChange,
40+
keyup: this.onKeyup,
41+
keydown: this.onKeydown
42+
}
43+
})
44+
);
45+
46+
// add the error element
47+
children.push(
48+
h('error-display', {
49+
props: {
50+
form: this.form,
51+
field: this.field.key
52+
}
53+
})
54+
);
55+
56+
// create the wrapper element
57+
return h('div', {
58+
'class': [
59+
'form-group formly-textarea',
60+
this.to.wrapperClasses,
61+
{
62+
'formly-has-value': this.model[ this.field.key ],
63+
'formly-has-focus': this.form[ this.field.key ].$active,
64+
'has-error has-danger': this.hasError
65+
}
66+
]
67+
}, children);
68+
}
69+
}

test/unit/specs/index.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,6 @@ describe('Bootstrap Field Inputs', () => {
365365
});
366366

367367
});
368-
369-
return;
370368

371369
describe('Textarea', () => {
372370
describe('functions', ()=>{
@@ -389,6 +387,8 @@ describe('Bootstrap Field Inputs', () => {
389387
expect(inputs).to.be.length(1);
390388
});
391389
});
390+
391+
return;
392392

393393
describe("List", () => {
394394
describe('checkbox functions', ()=>{

0 commit comments

Comments
 (0)