public function DashboardForm::form in Dashboards with Layout Builder 8
Same name and namespace in other branches
- 2.0.x src/Form/DashboardForm.php \Drupal\dashboards\Form\DashboardForm::form()
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ DashboardForm.php, line 16
Class
- DashboardForm
- Default config form.
Namespace
Drupal\dashboards\FormCode
public function form(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$form['#tree'] = TRUE;
$form['admin_label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Administrative Label'),
'#default_value' => $entity
->label(),
'#size' => 30,
'#required' => TRUE,
'#maxlength' => 64,
'#description' => $this
->t('The admin label for this dashboard.'),
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $entity
->id(),
'#required' => TRUE,
'#disabled' => !$entity
->isNew(),
'#size' => 30,
'#maxlength' => 64,
'#machine_name' => [
'exists' => [
'\\Drupal\\dashboards\\Entity\\Dashboard',
'load',
],
'source' => [
'admin_label',
],
],
];
$form['category'] = [
'#type' => 'textfield',
'#title' => $this
->t('Category'),
'#default_value' => $entity->category,
];
$form['frontend'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show always in frontend theme.'),
'#default_value' => $entity->frontend,
];
$form['weight'] = [
'#type' => 'number',
'#title' => $this
->t('Weight.'),
'#default_value' => $entity->weight,
];
return $form;
}