diff --git a/js/components/text_input.js b/js/components/text_input.js index 51972d82..75c9d5f0 100644 --- a/js/components/text_input.js +++ b/js/components/text_input.js @@ -1,7 +1,7 @@ import MaskedInput, { conformToMask } from 'vue-text-mask' import inputValidations from '../lib/input_validations' import { formatDollars } from '../lib/dollars' -import { emitFieldChange } from '../lib/emitters' +import { emitFieldChange, emitFieldMount } from '../lib/emitters' export default { name: 'textinput', @@ -27,6 +27,7 @@ export default { paragraph: String, noMaxWidth: String, optional: Boolean, + parent_uid: String, }, data: function() { @@ -67,9 +68,9 @@ export default { }, created: function() { - this.$root.$emit('field-mount', { - name: this.name, + emitFieldMount(this, { optional: this.optional, + name: this.name, }) }, diff --git a/js/lib/emitters.js b/js/lib/emitters.js index 8bed5096..c4cc3bf4 100644 --- a/js/lib/emitters.js +++ b/js/lib/emitters.js @@ -4,3 +4,10 @@ export const emitFieldChange = (el, data) => { parent_uid: el.$parent && el.$parent._uid, }) } + +export const emitFieldMount = (el, data) => { + el.$root.$emit('field-mount', { + ...data, + parent_uid: el.$parent && el.$parent._uid, + }) +}