Skip to content

Commit b7a69f4

Browse files
committed
Added placeholder, pattern, and autocomplete props and value data property to FormElement component
1 parent 153ee24 commit b7a69f4

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/components/utilities/FormElement.vue

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@
33
<label :for="name"><slot></slot></label>
44

55
<div v-if="this.required" class="input-group">
6-
<input v-if="this.required" class="form-control" :type="type" :name="name" :id="name" required>
6+
<input
7+
v-if="this.required"
8+
v-model="value"
9+
class="form-control"
10+
:type="type"
11+
:name="name"
12+
:placeholder="placeholder"
13+
:pattern="pattern"
14+
:autocomplete="autocomplete"
15+
:id="name"
16+
required
17+
>
718
<div class="invalid-feedback">
819
<p>The given value is not valid</p>
920
</div>
1021
</div>
1122
<div v-else class="input-group">
12-
<input class="form-control" :type="type" :name="name" :id="name">
23+
<input v-model="value" class="form-control" :type="type" :name="name" :placeholder="placeholder" :pattern="pattern" :autocomplete="autocomplete" :id="name">
1324
</div>
1425
</div>
1526
</template>
@@ -25,10 +36,24 @@ export default {
2536
type: String,
2637
default: 'text'
2738
},
39+
placeholder: {
40+
type: String
41+
},
42+
pattern: {
43+
type: String
44+
},
45+
autocomplete: {
46+
type: String
47+
},
2848
required: {
2949
type: Boolean,
3050
default: false
3151
}
52+
},
53+
data: function () {
54+
return {
55+
value: null
56+
};
3257
}
3358
};
3459
</script>

0 commit comments

Comments
 (0)