FormField.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div class="field">
  3. <label class="label" v-html="label"></label>
  4. <div class="control">
  5. <input :id="fieldName" :type="inputType" class="input" v-model="form[fieldName]" :placeholder="placeholder" v-bind="$attrs" />
  6. </div>
  7. <field-error :form="form" :field="fieldName" />
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. name: 'FormField',
  13. inheritAttrs: false,
  14. data() {
  15. return {
  16. }
  17. },
  18. props: {
  19. label: {
  20. type: String,
  21. default: ''
  22. },
  23. fieldName: {
  24. type: String,
  25. default: '',
  26. required: true
  27. },
  28. inputType: {
  29. type: String,
  30. default: 'text'
  31. },
  32. form: {
  33. type: Object,
  34. required: true
  35. },
  36. placeholder: {
  37. type: String,
  38. default: ''
  39. },
  40. }
  41. }
  42. </script>