You are here

public function MultiblockDeleteForm::buildForm in MultiBlock 8

Same name in this branch
  1. 8 src/MultiblockDeleteForm.php \Drupal\multiblock\MultiblockDeleteForm::buildForm()
  2. 8 src/Form/MultiblockDeleteForm.php \Drupal\multiblock\Form\MultiblockDeleteForm::buildForm()

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 FormInterface::buildForm

File

src/Form/MultiblockDeleteForm.php, line 18

Class

MultiblockDeleteForm

Namespace

Drupal\multiblock\Form

Code

public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state, $delta = NULL) {
  $block = multiblock_get_block($delta);
  if (empty($block)) {
    drupal_set_message(t('The multiblock with the delta @delta was not found.', [
      '@delta' => $delta,
    ]), 'error');
    return [];
  }
  $form['delta'] = [
    '#type' => 'value',
    '#value' => $delta,
  ];
  return confirm_form($form, t('Delete the block instance %title?', [
    '%title' => $block->title,
  ]), 'admin/structure/block/instances', t('This will delete the instance of the block %title.', [
    '%title' => $block->title,
  ]), t('Delete'), t('Cancel'));
}