You are here

protected function AjaxCommentsForm::setWrapperId in AJAX Comments 8

Set the wrapper id on the hidden element and the #ajax button properties.

Parameters

array $form: The form array.

string $wrapper_html_id: The value for the wrapper id.

2 calls to AjaxCommentsForm::setWrapperId()
AjaxCommentsForm::buildForm in src/Form/AjaxCommentsForm.php
Form constructor.
AjaxCommentsForm::validateForm in src/Form/AjaxCommentsForm.php
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level…

File

src/Form/AjaxCommentsForm.php, line 193

Class

AjaxCommentsForm
Provides ajax enhancements to core default Comment form.

Namespace

Drupal\ajax_comments\Form

Code

protected function setWrapperId(&$form, $wrapper_html_id) {

  // Add the wrapping fields's HTML id as a hidden input
  // so we can access it in the controller.
  $form['wrapper_html_id']['#value'] = $wrapper_html_id;
  $form['actions']['submit']['#ajax']['wrapper'] = $wrapper_html_id;
  if (isset($form['actions']['cancel']['#ajax'])) {
    $form['actions']['cancel']['#ajax']['wrapper'] = $wrapper_html_id;
  }
}