You are here

public function ConditionDeleteForm::buildForm in Context 8

Same name and namespace in other branches
  1. 8.4 modules/context_ui/src/Form/ConditionDeleteForm.php \Drupal\context_ui\Form\ConditionDeleteForm::buildForm()
  2. 8.0 modules/context_ui/src/Form/ConditionDeleteForm.php \Drupal\context_ui\Form\ConditionDeleteForm::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 ConfirmFormBase::buildForm

File

modules/context_ui/src/Form/ConditionDeleteForm.php, line 88

Class

ConditionDeleteForm

Namespace

Drupal\context_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, ContextInterface $context = NULL, $condition_id = NULL) {
  $this->context = $context;
  $this->condition = $context
    ->getCondition($condition_id);
  $form = parent::buildForm($form, $form_state);

  // Remove the cancel button if this is an AJAX request since Drupals built
  // in modal dialogues does not handle buttons that are not a primary
  // button very well.
  if ($this
    ->getRequest()
    ->isXmlHttpRequest()) {
    unset($form['actions']['cancel']);
  }

  // Submit the form with AJAX if possible.
  $form['actions']['submit']['#ajax'] = [
    'callback' => '::submitFormAjax',
  ];
  return $form;
}