customfields.js 941 B

1234567891011121314151617181920212223242526
  1. Vue.component('tab-customfields', {
  2. props: ['saved', 'errors', 'formdata', 'schema'],
  3. template: '<section><form>' +
  4. '<component v-for="(field, index) in schema.fields"' +
  5. ':key="index"' +
  6. ':is="selectComponent(field)"' +
  7. ':errors="errors"' +
  8. ':name="index"' +
  9. 'v-model="formdata[index]"' +
  10. 'v-bind="field">' +
  11. '</component>' +
  12. '<div v-if="saved" class="metaLarge"><div class="metaSuccess">Saved successfully</div></div>' +
  13. '<div v-if="errors" class="metaLarge"><div class="metaErrors">Please correct the errors above</div></div>' +
  14. '<div class="large"><input type="submit" @click.prevent="saveInput" value="save"></input></div>' +
  15. '</form></section>',
  16. methods: {
  17. selectComponent: function(field)
  18. {
  19. return 'component-'+field.type;
  20. },
  21. saveInput: function()
  22. {
  23. this.$emit('saveform');
  24. },
  25. }
  26. })