public function DashboardLayoutBuilderForm::buildForm in Dashboards with Layout Builder 8
Same name and namespace in other branches
- 2.0.x src/Form/DashboardLayoutBuilderForm.php \Drupal\dashboards\Form\DashboardLayoutBuilderForm::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 EntityForm::buildForm
File
- src/
Form/ DashboardLayoutBuilderForm.php, line 93
Class
- DashboardLayoutBuilderForm
- DashboardLayoutBuilderForm class.
Namespace
Drupal\dashboards\FormCode
public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL) {
$form['layout_builder'] = [
'#type' => 'layout_builder',
'#section_storage' => $section_storage,
'#attached' => [
'library' => [
'dashboards/core',
],
'drupalSettings' => [
'dashboards' => [
'colormap' => $this->config
->get('colormap') ? $this->config
->get('colormap') : 'summer',
'alpha' => $this->config
->get('alpha') ? $this->config
->get('alpha') / 100 : 80,
'shades' => $this->config
->get('shades') ? $this->config
->get('shades') : 15,
],
],
],
];
$this->sectionStorage = $section_storage;
$form = parent::buildForm($form, $form_state);
if ($section_storage instanceof UserDashboardSectionStorage) {
$form['actions']['reset'] = [
'#type' => 'submit',
'#value' => $this
->t('Reset to default'),
'#weight' => 10,
'#submit' => [
'::resetToDefault',
],
];
}
return $form;
}