function BlockContentForm::form

Same name in other branches
  1. 9 core/modules/block_content/src/BlockContentForm.php \Drupal\block_content\BlockContentForm::form()
  2. 10 core/modules/block_content/src/BlockContentForm.php \Drupal\block_content\BlockContentForm::form()
  3. 11.x core/modules/block_content/src/BlockContentForm.php \Drupal\block_content\BlockContentForm::form()

Overrides ContentEntityForm::form

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.