AK
Size: a a a
VS
C
C
VS
АК
AI
АК
VS
AI
АК
АК
use Drupal\Core\Form\FormStateInterface;
use Drupal\system\Entity\Menu;
/**
* Implements hook_form_alter().
*
* @param $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
* @param $form_id
*/
function my_module_form_menu_link_content_menu_link_content_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$menu = \Drupal::routeMatch()->getParameter('menu');
if (!($menu instanceof Menu)) {
return;
}
$filtered_options = [];
$id = $menu->id();
foreach ($form['menu_parent']['#options'] as $key => $option) {
if (str_starts_with($key, $id)) {
$filtered_options[$key] = $option;
}
}
$form['menu_parent']['#options'] = $filtered_options;
}DL
DD
DL