forked from area17/twill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHiddenField.vue
executable file
·49 lines (46 loc) · 1.07 KB
/
HiddenField.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<template>
<div class="form__input form__input--hidden">
<input type="hidden" :name="name" :id="uniqId" :value="value" />
</div>
</template>
<script>
import randKeyMixin from '@/mixins/randKey'
import InputMixin from '@/mixins/input'
import FormStoreMixin from '@/mixins/formStore'
export default {
name: 'A17HiddenField',
mixins: [randKeyMixin, InputMixin, FormStoreMixin],
props: {
name: {
type: String,
required: true
},
initialValue: {
default: ''
}
},
computed: {
uniqId: function () {
return this.name + '-' + this.randKey
}
},
data: function () {
return {
value: this.initialValue
}
},
watch: {
initialValue: function () {
this.value = this.initialValue
}
},
methods: {
updateFromStore: function (newValue) { // called from the formStore mixin
if (typeof newValue === 'undefined') newValue = ''
if (this.value !== newValue) {
this.value = newValue
}
}
}
}
</script>