You are here

public function NiceMenusBlock::blockForm in Nice Menus 8

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/NiceMenusBlock.php, line 67

Class

NiceMenusBlock
Provides a 'Nice menus' block.

Namespace

Drupal\nice_menus\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form = parent::blockForm($form, $form_state);
  $config = $this
    ->getConfiguration();
  $form['nice_menus_name'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Menu name'),
    '#default_value' => isset($config['nice_menus_name']) ? $config['nice_menus_name'] : '',
  );
  $form['nice_menus_menu'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Menu parent'),
    '#description' => $this
      ->t('The menu parent from which to show a Nice menu.'),
    '#default_value' => isset($config['nice_menus_menu']) ? $config['nice_menus_menu'] : 'navigation:0',
    '#options' => $this->menuSelector
      ->getParentSelectOptions(),
  );
  $form['nice_menus_depth'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Menu depth'),
    '#description' => $this
      ->t('The depth of the menu, i.e. the number of child levels starting with the parent selected above. Leave set to -1 to display all children and use 0 to display no children.'),
    '#default_value' => isset($config['nice_menus_depth']) ? $config['nice_menus_depth'] : -1,
    '#options' => array_combine(range(-1, 5), range(-1, 5)),
  );
  $form['nice_menus_type'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Menu style'),
    '#description' => $this
      ->t('right: menu items are listed on top of each other and expand to the right') . '<br />' . $this
      ->t('left: menu items are listed on top of each other and expand to the left') . '<br />' . $this
      ->t('down: menu items are listed side by side and expand down'),
    '#default_value' => isset($config['nice_menus_type']) ? $config['nice_menus_type'] : 'right',
    '#options' => array_combine(array(
      'right',
      'left',
      'down',
    ), array(
      'right',
      'left',
      'down',
    )),
  );
  $form['nice_menus_respect_expand'] = array(
    '#type' => 'select',
    '#title' => $this
      ->t('Respect "Show as expanded" option'),
    '#description' => $this
      ->t('Menu items have a "Show as expanded" option, which is disabled by default. Since menu items do NOT have this option checked by default, you should choose Yes here once you have configured the menu items that you DO want to expand.'),
    '#options' => array(
      0 => $this
        ->t('No'),
      1 => $this
        ->t('Yes'),
    ),
    '#default_value' => isset($config['nice_menus_respect_expand']) ? $config['nice_menus_respect_expand'] : 0,
  );
  return $form;
}