Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 71b6a9c

Browse files
authored
Merge pull request #17 from alvarosaburido/bug/custom_classes_not_working
Added customClasses and fix small stuff
2 parents f96d139 + 8a1b5e7 commit 71b6a9c

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

dev/App.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<dynamic-form
88
:id="testForm.id"
99
:fields="testForm.fields"
10+
:customClass="'row'"
1011
@change="valuesChanged"
1112
>
1213
<template slot="custom-field-1" slot-scope="props">
@@ -59,11 +60,13 @@ const data = () => ({
5960
type: 'text',
6061
label: 'Name',
6162
name: 'name',
63+
customClass: 'col-12',
6264
}),
6365
new FormField({
6466
type: 'email',
6567
label: 'Email',
6668
name: 'email',
69+
customClass: 'col-12',
6770
validations: [
6871
new FormValidation(required, 'This field is required'),
6972
new FormValidation(email, 'Format of email is incorrect'),
@@ -73,6 +76,7 @@ const data = () => ({
7376
type: 'password',
7477
label: 'Password',
7578
name: 'password',
79+
customClass: 'col-12',
7680
validations: [
7781
new FormValidation(required, 'This field is required'),
7882
new FormValidation(
@@ -91,11 +95,13 @@ const data = () => ({
9195
name: 'bio',
9296
cols: 30,
9397
rows: 5,
98+
customClass: 'col-12',
9499
}),
95100
new FormField({
96101
type: 'select',
97102
label: 'Category',
98103
name: 'category',
104+
customClass: 'col-12',
99105
options: [
100106
{ value: null, text: 'Please select an option' },
101107
{ value: 'arduino', text: 'Arduino' },
@@ -108,12 +114,14 @@ const data = () => ({
108114
label: 'Read the conditions',
109115
name: 'conditions',
110116
inline: false,
117+
customClass: 'col-12',
111118
}),
112119
new FormField({
113120
type: 'radio',
114121
label: 'Prefered Animal',
115122
name: 'animal',
116123
inline: true,
124+
customClass: 'col-12',
117125
options: [
118126
{ text: 'Dogs', value: 'dogs' },
119127
{ text: 'Cats', value: 'cats' },
@@ -124,18 +132,21 @@ const data = () => ({
124132
type: 'custom-field',
125133
label: 'Custom Field 1',
126134
name: 'custom-field-1',
135+
customClass: 'col-12',
127136
}),
128137
new FormField({
129138
type: 'number',
130139
label: 'Number',
131140
name: 'number',
132141
value: 0,
142+
customClass: 'col-12 col-md-6',
133143
}),
134-
135144
new FormField({
136-
type: 'custom-field',
137-
label: 'File',
138-
name: 'custom-field-2',
145+
type: 'number',
146+
label: 'Number 2',
147+
name: 'number2',
148+
value: 50,
149+
customClass: 'col-12 col-md-6',
139150
}),
140151
],
141152
},
@@ -163,7 +174,8 @@ export default {
163174
164175
img {
165176
position: absolute;
166-
right: 0;
177+
top: 5px;
178+
right: 5px;
167179
}
168180
}
169181
</style>

src/components/dynamic-form/DynamicForm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const props = {
2121
default: 'POST',
2222
type: String,
2323
},
24-
classes: {
24+
customClass: {
2525
default: null,
2626
type: String,
2727
},

src/components/dynamic-form/DynamicForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
v-if="fields.length > 0 && !showFeedback"
55
:id="id"
66
:name="id"
7-
:class="classes"
7+
:class="customClass"
88
:method="method"
99
novalidate
1010
@submit.prevent="handleSubmit()"

src/components/dynamic-input/DynamicInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div
33
class="dynamic-input form-group"
4-
:class="{ 'form-group--error': hasErrors }"
4+
:class="({ 'form-group--error': hasErrors }, `${formControl.customClass || ''}`)"
55
>
66
<label
77
class="form-label"

src/core/utils/form-control.model.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export function FormControl({
44
validations = [],
55
label = null,
66
name = null,
7+
customClass = null,
78
options = [],
89
placeholder = null,
910
errors = {},
@@ -16,6 +17,7 @@ export function FormControl({
1617
this.validations = validations;
1718
this.label = label;
1819
this.name = name;
20+
this.customClass = customClass;
1921
this.options = options;
2022
this.placeholder = placeholder;
2123
this.errors = errors;

0 commit comments

Comments
 (0)