I have a custom content entity and i'd like to use a map
BaseFieldDefinition type to hold an arbitrary number of options.
This is in my custom content entity baseFieldsDefinitions()
:
$fields['options'] = BaseFieldDefinition::create('integer')
->setLabel(t('Task options'))
->setDescription(t('The task options.'))
->setSettings(array(
'type' => 'map',
'default_value' => null
));
How do I display this as part of the entity form?
My instinct is that I'd need to create a custom widget, custom formatter and add the following to the base field definition:
->setDisplayOptions('form', array(
'type' => 'custom_widget',
'weight' => -6,
))
Any direction would be much appreciated.
BaseFieldDefinition::create('map')
, remove the->setSettings(...)
, write my custom widget and then declare it in thesetDisplayOptions('form', ...)
as above? – RobotEyes Mar 14 '17 at 10:38