I am creating a Field plugin, where I have requirement as below
Field name : Question
Properties:
Question Text : String
Question Type : integer (0,1,2)
Question Options : Array of Strings
I defined schema like this. I am not sure if I am doing it right for Question Option
public static function schema(FieldStorageDefinitionInterface $field_definition) {
$schema = [
'columns' => [
'question_text' => [
'type' => 'varchar',
],
'option_type' => [
'description' => 'Option Type: 0 = radio, 1 = checkbox',
'type' => 'int',
'default' => 0,
],
'question_option' => [
'type' => 'varchar',
'serialize' => TRUE,
],
],
];
return $schema;
}
And for property definition I have following
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties['question_text'] = DataDefinition::create('string');
$properties['option_type'] = DataDefinition::create('integer');
$properties['question_option'] = DataDefinition::create('string');
return $properties;
}
Please let me know how can I do it for the question_option.
--
Thanks