function LayoutForm::buildForm
Same name and namespace in other branches
- 10 core/modules/navigation/src/Form/LayoutForm.php \Drupal\navigation\Form\LayoutForm::buildForm()
- 11.x core/modules/navigation/src/Form/LayoutForm.php \Drupal\navigation\Form\LayoutForm::buildForm()
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 FormInterface::buildForm
File
-
core/
modules/ navigation/ src/ Form/ LayoutForm.php, line 81
Class
- LayoutForm
- Defines a form for configuring navigation blocks.
Namespace
Drupal\navigation\FormCode
public function buildForm(array $form, FormStateInterface $form_state, ?SectionStorageInterface $section_storage = NULL) {
$form['#prefix'] = '<div id="js-config-form-wrapper">';
$form['#suffix'] = '</div>';
$form['#attributes']['class'][] = 'layout-builder-form';
$this->sectionStorage = $section_storage;
$form['layout_builder'] = [
'#type' => 'layout_builder',
'#section_storage' => $section_storage,
];
$form['#attached']['library'][] = 'navigation/navigation.layoutBuilder';
$form['actions'] = [
'enable_edit_mode' => [
'#type' => 'submit',
'#value' => $this->t('Enable edit mode'),
'#name' => 'enable_edit_mode',
'#ajax' => [
'callback' => '::enableEditMode',
'wrapper' => 'js-config-form-wrapper',
'effect' => 'fade',
],
],
'submit' => [
'#type' => 'submit',
'#value' => $this->t('Save'),
'#name' => 'save',
],
] + $this->buildActionsElement([]);
$this->handleFormElementsVisibility($form, FALSE);
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.