public function LayoutForm::form in Bootstrap Layout Builder 1.x
Same name and namespace in other branches
- 2.x src/Form/LayoutForm.php \Drupal\bootstrap_layout_builder\Form\LayoutForm::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/ LayoutForm.php, line 45
Class
- LayoutForm
- Class LayoutForm.
Namespace
Drupal\bootstrap_layout_builder\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\bootstrap_layout_builder\LayoutInterface $layout */
$layout = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $layout
->label(),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $layout
->id(),
'#machine_name' => [
'exists' => '\\Drupal\\bootstrap_layout_builder\\Entity\\Layout::load',
],
'#disabled' => !$layout
->isNew(),
];
$form['number_of_columns'] = [
'#type' => 'textfield',
'#title' => $this
->t('Number of columns'),
'#description' => $this
->t('The number of columns (Regions) at this layout.'),
'#default_value' => $layout
->getNumberOfColumns(),
'#maxlength' => 3,
'#required' => TRUE,
'#disabled' => TRUE,
];
return $form;
}