<template>
  <u-radio-group v-model="value" @change="change" :disabled="!config.writable">
    <u-radio v-for="(item, index) in options" :key="index" :name="item.value" :disabled="item.disabled">
      {{ item.label }}
    </u-radio>
  </u-radio-group>
</template>

<script>
  export default {
    name: 'RADIO',
    props: ['config', 'onChange'],
    data() {
      return {
        value: '',
        options: []
      }
    },
    created() {
      this.value = this.config.value || ''
      this.options = this.config.options || []
    },
    methods: {
      change(val) {
        this.onChange({ prop: this.config.formName, value: val })
      }
    }
  }
</script>

<style></style>
