You are here

public function BlockContentForm::form in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block_content/src/BlockContentForm.php \Drupal\block_content\BlockContentForm::form()
  2. 9 core/modules/block_content/src/BlockContentForm.php \Drupal\block_content\BlockContentForm::form()

Gets the actual form array to be built.

Overrides ContentEntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

core/modules/block_content/src/BlockContentForm.php, line 26

Class

BlockContentForm
Form handler for the custom block edit forms.

Namespace

Drupal\block_content

Code

public function form(array $form, FormStateInterface $form_state) {
  $block = $this->entity;
  $form = parent::form($form, $form_state);
  if ($this->operation == 'edit') {
    $form['#title'] = $this
      ->t('Edit custom block %label', [
      '%label' => $block
        ->label(),
    ]);
  }

  // Override the default CSS class name, since the user-defined custom block
  // type name in 'TYPE-block-form' potentially clashes with third-party class
  // names.
  $form['#attributes']['class'][0] = 'block-' . Html::getClass($block
    ->bundle()) . '-form';
  return $form;
}