You are here

public function GeysirModalParagraphDeleteForm::buildForm in Geysir 8

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

File

src/Form/GeysirModalParagraphDeleteForm.php, line 32

Class

GeysirModalParagraphDeleteForm
Functionality to delete a paragraph through a modal.

Namespace

Drupal\geysir\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $form['#prefix'] = '<div id="geysir-modal-form">';
  $form['#suffix'] = '</div>';

  // @TODO: fix problem with form is outdated.
  $form['#token'] = FALSE;

  // Define alternative submit callbacks using AJAX by copying the default
  // submit callbacks to the AJAX property.
  $submit =& $form['actions']['submit'];
  $submit['#ajax'] = [
    'callback' => '::ajaxDelete',
    'event' => 'click',
    'progress' => [
      'type' => 'throbber',
      'message' => NULL,
    ],
  ];
  $form['actions']['cancel'] = [
    '#type' => 'button',
    '#value' => t('Cancel'),
    '#ajax' => [
      'callback' => '::ajaxCancel',
      'event' => 'click',
    ],
  ];
  return $form;
}