parentSelectElement example


        ];
        $form['menu']['expanded'] = [
          '#title' => $this->t('Show as expanded'),
          '#type' => 'checkbox',
          '#default_value' => !empty($menu['expanded']),
          '#description' => $this->t('If selected and this menu link has children, the menu will always appear expanded.'),
        ];

        $menu_parent = $menu['menu_name'] . ':' . $menu['parent'];
        $menu_link = 'views_view:views.' . $form_state->get('view')->id() . '.' . $form_state->get('display_id');
        $form['menu']['parent'] = $this->parentFormSelector->parentSelectElement($menu_parent$menu_link);
        $form['menu']['parent'] += [
          '#title' => $this->t('Parent'),
          '#description' => $this->t('The maximum depth for a link and all its children is fixed. Some menu links may not be available as parents if selecting them would exceed this limit.'),
          '#attributes' => ['class' => ['menu-title-select']],
          '#states' => [
            'visible' => [
              [
                ':input[name="menu[type]"]' => ['value' => 'normal'],
              ],
              [
                ':input[name="menu[type]"]' => ['value' => 'tab'],
              ],
'#default_value' => $this->menuLink->isEnabled(),
    ];

    $form['expanded'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Show as expanded'),
      '#description' => $this->t('If selected and this menu link has children, the menu will always appear expanded. This option may be overridden for the entire menu tree when placing a menu block.'),
      '#default_value' => $this->menuLink->isExpanded(),
    ];

    $menu_parent = $this->menuLink->getMenuName() . ':' . $this->menuLink->getParent();
    $form['menu_parent'] = $this->menuParentSelector->parentSelectElement($menu_parent$this->menuLink->getPluginId());
    $form['menu_parent']['#title'] = $this->t('Parent link');
    $form['menu_parent']['#description'] = $this->t('The maximum depth for a link and all its children is fixed. Some menu links may not be available as parents if selecting them would exceed this limit.');
    $form['menu_parent']['#attributes']['class'][] = 'menu-title-select';

    $delta = max(abs($this->menuLink->getWeight()), 50);
    $form['weight'] = [
      '#type' => 'number',
      '#min' => -$delta,
      '#max' => $delta,
      '#default_value' => $this->menuLink->getWeight(),
      '#title' => $this->t('Weight'),
      

    $form['displays']['page']['options']['link_properties'] = [
      '#type' => 'container',
      '#states' => [
        'visible' => [
          ':input[name="page[link]"]' => ['checked' => TRUE],
        ],
      ],
      '#prefix' => '<div id="edit-page-link-properties-wrapper">',
      '#suffix' => '</div>',
    ];
    $form['displays']['page']['options']['link_properties']['parent'] = $this->parentFormSelector->parentSelectElement('admin:');
    $form['displays']['page']['options']['link_properties']['parent'] += [
      '#title' => $this->t('Menu'),
    ];
    $form['displays']['page']['options']['link_properties']['title'] = [
      '#title' => $this->t('Link text'),
      '#type' => 'textfield',
    ];
    // Only offer a feed if we have at least one available feed row style.     if ($feed_row_options) {
      $form['displays']['page']['options']['feed'] = [
        '#title' => $this->t('Include an RSS feed'),
        

  }

  /** * {@inheritdoc} */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form$form_state);

    $default = $this->entity->getMenuName() . ':' . $this->entity->getParentId();
    $id = $this->entity->isNew() ? '' : $this->entity->getPluginId();
    $form['menu_parent'] = $this->menuParentSelector->parentSelectElement($default$id);
    $form['menu_parent']['#weight'] = 10;
    $form['menu_parent']['#title'] = $this->t('Parent link');
    $form['menu_parent']['#description'] = $this->t('The maximum depth for a link and all its children is fixed. Some menu links may not be available as parents if selecting them would exceed this limit.');
    $form['menu_parent']['#attributes']['class'][] = 'menu-title-select';

    return $form;
  }

  /** * {@inheritdoc} */
  
Home | Imprint | This part of the site doesn't use cookies.