public function SystemMenuBlock::blockForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Plugin/Block/SystemMenuBlock.php \Drupal\system\Plugin\Block\SystemMenuBlock::blockForm()
Returns the configuration form elements specific to this block plugin.
Blocks that need to add form elements to the normal block configuration form should implement this method.
Parameters
array $form: The form definition array for the block configuration form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array $form The renderable form array representing the entire configuration form.
Overrides BlockBase::blockForm
File
- core/
modules/ system/ src/ Plugin/ Block/ SystemMenuBlock.php, line 80 - Contains \Drupal\system\Plugin\Block\SystemMenuBlock.
Class
- SystemMenuBlock
- Provides a generic Menu block.
Namespace
Drupal\system\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
$config = $this->configuration;
$defaults = $this
->defaultConfiguration();
$form['menu_levels'] = array(
'#type' => 'details',
'#title' => $this
->t('Menu levels'),
// Open if not set to defaults.
'#open' => $defaults['level'] !== $config['level'] || $defaults['depth'] !== $config['depth'],
'#process' => [
[
get_class(),
'processMenuLevelParents',
],
],
);
$options = range(0, $this->menuTree
->maxDepth());
unset($options[0]);
$form['menu_levels']['level'] = array(
'#type' => 'select',
'#title' => $this
->t('Initial menu level'),
'#default_value' => $config['level'],
'#options' => $options,
'#description' => $this
->t('The menu will only be visible if the menu item for the current page is at or below the selected starting level. Select level 1 to always keep this menu visible.'),
'#required' => TRUE,
);
$options[0] = $this
->t('Unlimited');
$form['menu_levels']['depth'] = array(
'#type' => 'select',
'#title' => $this
->t('Maximum number of menu levels to display'),
'#default_value' => $config['depth'],
'#options' => $options,
'#description' => $this
->t('The maximum number of menu levels to show, starting from the initial menu level. For example: with an initial level 2 and a maximum number of 3, menu levels 2, 3 and 4 can be displayed.'),
'#required' => TRUE,
);
return $form;
}