public function MenuTrailByPathSettingsForm::buildForm in Menu Trail By Path 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ MenuTrailByPathSettingsForm.php, line 45
Class
- MenuTrailByPathSettingsForm
- Configures menu trail by path settings for this site.
Namespace
Drupal\menu_trail_by_path\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('menu_trail_by_path.settings');
$form['max_path_parts'] = [
'#type' => 'number',
'#min' => 0,
'#size' => 30,
'#title' => $this
->t('Maximum path parts'),
'#default_value' => $config
->get('max_path_parts'),
'#description' => $this
->t('Configures how deep the module should go when resolving active trail links. Setting this value to zero will not limit the number of the path parts. It is recommended to configure the path parts and enabled menu to only those that require it, to avoid unnecessary performance overhead. The path setting only applies when using the by path option.'),
];
$form['trail_source'] = [
'#type' => 'radios',
'#title' => $this
->t('Trail Source'),
'#description' => $this
->t('Configures the global behavior for the trail source. The trail source default can be overriden for each menu in the menu settings.'),
'#options' => static::getTrailSourceOptions(),
'#default_value' => $config
->get('trail_source'),
];
$form['trail_source'][MenuTrailByPathActiveTrail::MENU_TRAIL_PATH]['#description'] = t('Attempt to find a matching parent menu link based on the path structure. Slower, especially with a large amount of paths parts to consider.');
$form['trail_source'][MenuTrailByPathActiveTrail::MENU_TRAIL_CORE]['#description'] = t('Active trail only for pages that have a menu link pointing to them, same as when not using this module.');
$form['trail_source'][MenuTrailByPathActiveTrail::MENU_TRAIL_DISABLED]['#description'] = t('No active trail at all. No performance overhead, useful for special/footer menus.');
return parent::buildForm($form, $form_state);
}