FAQ

Can I create conditional fields or logic?

Yes; you can create a custom field type to allow conditional fields and even advanced logic. We prepared a simple example on such a conditional field for you.

const Fieldtype = {
  mixins: [window.Storyblok.plugin],
  template: `<div>
  <div class="uk-form-label">Do you have a headset?</div>
  <label><input type="radio" v-model="model.has_headset" :value="true" /> Yes</label>
  <label><input type="radio" v-model="model.has_headset" :value="false" class="uk-margin-small-left" /> No</label>
  <div v-if="model.has_headset" class="uk-margin-small-top">
    <div class="uk-form-label">How many?</div>
    <input class="uk-width-1-1" v-model="model.number_of_headsets" type="number" />
  </div>
</div>`,
  methods: {
    initWith() {
      return {
        plugin: 'example_plugin',
        has_headset: false,
        number_of_headsets: 0
      }
    },
    pluginCreated() {
      
    }
  },
  watch: {
    'model': {
      handler: function (value) {
        this.$emit('changed-model', value);
      },
      deep: true
    }
  }
}