You are here

protected function WebformEntityReferenceTrait::buildAjaxElementTriggerRecursive in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/WebformEntityReferenceTrait.php \Drupal\webform\Plugin\WebformElement\WebformEntityReferenceTrait::buildAjaxElementTriggerRecursive()

Build an ajax elements trigger.

Parameters

string $id: The id used to create the ajax wrapper and trigger.

array &$element: The elements to trigger the Ajax update.

1 call to WebformEntityReferenceTrait::buildAjaxElementTriggerRecursive()
WebformEntityReferenceTrait::form in src/Plugin/WebformElement/WebformEntityReferenceTrait.php

File

src/Plugin/WebformElement/WebformEntityReferenceTrait.php, line 632

Class

WebformEntityReferenceTrait
Provides an 'entity_reference' trait.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function buildAjaxElementTriggerRecursive($id, array &$element) {
  $element['#access'] = TRUE;
  foreach (Element::children($element) as $key) {

    // Replace #ajax = TRUE with custom ajax element trigger attribute.
    if (isset($element[$key]['#ajax']) && $element[$key]['#ajax'] === TRUE) {
      $this
        ->buildAjaxElementTrigger($id, $element[$key]);
    }
    unset($element[$key]['#ajax'], $element[$key]['#limit_validation_errors']);
    $this
      ->buildAjaxElementTriggerRecursive($id, $element[$key]);
  }
}