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

Commit f3fce6e

Browse files
committed
Configurable id, default with form id to avoid duplicated ids
1 parent 90dc4b7 commit f3fce6e

File tree

6 files changed

+13
-3
lines changed

6 files changed

+13
-3
lines changed

dev/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ const data = () => ({
147147
customClass: 'col-12',
148148
}),
149149
new FormField({
150+
id: 'number-custom-id',
150151
type: 'number',
151152
label: 'Number',
152153
name: 'number',

src/components/dynamic-form/DynamicForm.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const methods = {
3434
field =>
3535
new FormControl({
3636
...field,
37+
form: this.id,
3738
}),
3839
);
3940
},
@@ -42,6 +43,7 @@ const methods = {
4243
field =>
4344
new FormControl({
4445
...field,
46+
form: this.id,
4547
}),
4648
);
4749
},
@@ -63,6 +65,7 @@ const methods = {
6365
field =>
6466
new FormControl({
6567
...field,
68+
form: this.id,
6669
valid: true,
6770
value: null,
6871
touched: false,

src/components/input-select/InputSelect.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<select
3-
:id="formControl.name"
3+
:id="formControl.id"
44
v-model="formControl.value"
55
:name="formControl.name"
66
class="form-control"

src/components/input-text/InputText.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<input
3-
:id="formControl.name"
3+
:id="formControl.id"
44
v-model="formControl.value"
55
:name="formControl.name"
66
class="form-control"

src/components/input-textarea/InputTextarea.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<textarea
3-
:id="formControl.name"
3+
:id="formControl.id"
44
v-model="formControl.value"
55
:name="formControl.name"
66
class="form-control"

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
export function FormControl({
2+
id,
23
type = null,
34
value = null,
45
validations = [],
56
label = null,
7+
form,
68
name = null,
79
customClass = null,
810
options = [],
@@ -14,7 +16,9 @@ export function FormControl({
1416
touched = false,
1517
dirty = false,
1618
}) {
19+
this.id = id || `${form}-${name}`;
1720
this.type = type;
21+
this.form = form;
1822
this.value = value;
1923
this.validations = validations;
2024
this.label = label;
@@ -31,6 +35,7 @@ export function FormControl({
3135
}
3236

3337
export function FormField({
38+
id,
3439
type = 'text',
3540
value = null,
3641
validations = [],
@@ -44,6 +49,7 @@ export function FormField({
4449
rows = null,
4550
cols = null,
4651
}) {
52+
this.id = id;
4753
this.type = type;
4854
this.value = value;
4955
this.validations = validations;

0 commit comments

Comments
 (0)