I've a custom module that alters the MenuLinkContent entity by adding a field. My field is defined as follow.
/**
* Implements hook_entity_base_field_info().
*/
function svg_icon_menu_link_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = array();
if ( $entity_type->get('id') !== 'menu_link_content' ) {
return $fields;
}
$fields['hide_label'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Hide label'))
->setDescription(t('Display only the icon.'))
->setDisplayOptions('form', array(
'type' => 'checkbox',
'weight' => 0
));
return $fields;
}
By default the checkbox is saved in the DB with a value of 0
if unchecked, and with a value of 1
if checked. To Drupal there's always a value for that field, that's why it prevent me to uninstall the module with the message There is data for the field hide_label on entity type Custom menu link
.
How should I manage this situation? Should I save a value of NULL
if unchecked in some way, or should I have to do something when uninstalling my custom module?