FormSelect.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div class="field">
  3. <label class="label" v-html="label"></label>
  4. <div class="control">
  5. <div class="select">
  6. <select v-model="form[fieldName]" v-on:change="$emit(fieldName, form[fieldName])">
  7. <option v-for="option in options" :value="option.value">{{ option.text }}</option>
  8. </select>
  9. </div>
  10. </div>
  11. <field-error :form="form" :field="fieldName" />
  12. <p class="help" v-html="help" v-if="help"></p>
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'FormSelect',
  18. data() {
  19. return {
  20. }
  21. },
  22. props: {
  23. label: {
  24. type: String,
  25. default: ''
  26. },
  27. fieldName: {
  28. type: String,
  29. default: '',
  30. required: true
  31. },
  32. options: {
  33. type: Array,
  34. required: true
  35. },
  36. form: {
  37. type: Object,
  38. required: true
  39. },
  40. help: {
  41. type: String,
  42. default: ''
  43. },
  44. }
  45. }
  46. </script>