FormField.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="field" :class="{ 'pt-3' : hasOffset }">
  3. <label class="label" v-html="label"></label>
  4. <div class="control">
  5. <input :disabled="isDisabled" :id="fieldName" :type="inputType" class="input" v-model="form[fieldName]" :placeholder="placeholder" v-bind="$attrs" v-on:change="$emit('field-changed', form[fieldName])"/>
  6. </div>
  7. <field-error :form="form" :field="fieldName" />
  8. <p class="help" v-html="help" v-if="help"></p>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'FormField',
  14. inheritAttrs: false,
  15. data() {
  16. return {
  17. }
  18. },
  19. props: {
  20. label: {
  21. type: String,
  22. default: ''
  23. },
  24. fieldName: {
  25. type: String,
  26. default: '',
  27. required: true
  28. },
  29. inputType: {
  30. type: String,
  31. default: 'text'
  32. },
  33. form: {
  34. type: Object,
  35. required: true
  36. },
  37. placeholder: {
  38. type: String,
  39. default: ''
  40. },
  41. help: {
  42. type: String,
  43. default: ''
  44. },
  45. hasOffset: {
  46. type: Boolean,
  47. default: false
  48. },
  49. isDisabled: {
  50. type: Boolean,
  51. default: false
  52. }
  53. }
  54. }
  55. </script>