BlockContentTypeDeleteForm::buildForm

public BlockContentTypeDeleteForm::buildForm(array $form, FormStateInterface $form_state)

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides EntityDeleteForm::buildForm

File

core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php, line 44

Class

BlockContentTypeDeleteForm
Provides a confirmation form for deleting a custom block type entity.

Namespace

Drupal\block_content\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $blocks = $this->queryFactory->get('block_content')->condition('type', $this->entity->id())->execute();
  if (!empty($blocks)) {
    $caption = '<p>' . $this->formatPlural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $this->entity->label())) . '</p>';
    $form['description'] = array('#markup' => $caption);
    return $form;
  }
  else {
    return parent::buildForm($form, $form_state);
  }
}
doc_Drupal
2016-10-29 08:47:10
Comments
Leave a Comment

Please login to continue.