You are here

public function BlockCategoryForm::form in Layout Builder Browser 8

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/BlockCategoryForm.php, line 38

Class

BlockCategoryForm
Form handler for the block categories add and edit forms.

Namespace

Drupal\layout_builder_browser\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);
  $layout_builder_browser = $this->entity;
  $form['label'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label'),
    '#maxlength' => 255,
    '#default_value' => $layout_builder_browser
      ->label(),
    '#description' => $this
      ->t("Label for the block category."),
    '#required' => TRUE,
  ];
  $form['id'] = [
    '#type' => 'machine_name',
    '#default_value' => $layout_builder_browser
      ->id(),
    '#machine_name' => [
      'exists' => [
        $this,
        'exist',
      ],
    ],
    '#disabled' => !$layout_builder_browser
      ->isNew(),
  ];

  // You will need additional form elements for your custom properties.
  return $form;
}