Skip to content

Commit 31255b1

Browse files
committed
added classes
1 parent 4698cf4 commit 31255b1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/fields/fieldInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="form-group">
33
<label v-if="form[key].label" :for="form[key].id ? form[key].id : null">{{form[key].label}}</label>
4-
<input class="form-control" :id="form[key].id ? form[key].id : null" :type="form[key].inputType" v-model="form[key].value" :placeholder="form[key].placeholder" @blur="onBlur" @focus="onFocus" @click="onClick" @change="onChange" @keyup="onKeyup" @keydown="onKeydown" v-formly-atts="form[key].atts">
4+
<input class="form-control" :class="form[key].classes" :id="form[key].id ? form[key].id : null" :type="form[key].inputType" v-model="form[key].value" :placeholder="form[key].placeholder" @blur="onBlur" @focus="onFocus" @click="onClick" @change="onChange" @keyup="onKeyup" @keydown="onKeydown" v-formly-atts="form[key].atts">
55
</div>
66
</template>
77

test/unit/specs/index.spec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ describe('Bootstrap Field Inputs', () => {
108108

109109
});
110110

111-
describe('attributes', () => {
112-
it('should pass attributes', () => {
111+
describe('classes & attributes', () => {
112+
it('attributes', () => {
113113
data.form.test.type = 'input';
114114
data.form.test.inputType = 'text';
115115
data.form.test.atts = {
@@ -121,6 +121,18 @@ describe('Bootstrap Field Inputs', () => {
121121
expect(input.dataset.foo).to.equal('bar');
122122
expect(input.dataset.bar).to.equal('foo');
123123
});
124+
125+
it('classes', () => {
126+
data.form.test.type = 'input';
127+
data.form.test.inputType = 'text';
128+
data.form.test.classes = {
129+
'class-a': true,
130+
'class-b': false
131+
};
132+
createForm();
133+
let input = vm.$el.querySelectorAll('input')[0];
134+
expect(input.className).to.equal('form-control class-a');
135+
});
124136
});
125137

126138
describe('input', () => {

0 commit comments

Comments
 (0)