I've added two new fields to the menu item form (admin/structure/menu/item/{ID}/edit):
function modulename_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
$fields = [];
if($entity_type->id() == 'menu_link_content') {
$fields['show_mobile'] = \Drupal\Core\Field\BaseFieldDefinition::create('boolean')
->setLabel(t('Show in mobile menu bar.'))
->setDescription(t('Toggles the display of the menu item in the menu bar at the bottom of pages in mobile view.'))
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => '0',
'settings' => [
'display_label' => TRUE,
],
])
->setDisplayConfigurable('form', TRUE);
$fields['svg_icon'] = \Drupal\Core\Field\BaseFieldDefinition::create('string')
->setLabel(t('Mobile Menu Bar SVG Icon'))
->setDescription(t('Select the icon you want the menu item to use in the mobile menu bar.'))
->setDisplayOptions('form', [
'type' => 'string',
'weight' => '0',
'settings' => [
'display_label' => TRUE,
],
])
->setDisplayConfigurable('form', TRUE);
}
return $fields;
}
But now I run into the issue, that I only need these fields for the main navigation menu, and thus want to remove or hide these on all other menu item forms.
Preferably I would like to keep it all to the module that adds the fields, and not have to create a custom admin theme just to visually hide them.
What should I look at to figure this one out? I've tried googling a lot of different combinations of the question, but have yet to find anything that remotely looks like a solution.
Many thanks in advance to anyone who can point me in the right direction.