You are here

protected function WebformSubmissionForm::alterElementsForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionForm.php \Drupal\webform\WebformSubmissionForm::alterElementsForm()

Alter webform elements form.

Parameters

array $elements: An render array representing elements.

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

1 call to WebformSubmissionForm::alterElementsForm()
WebformSubmissionForm::buildForm in src/WebformSubmissionForm.php
Form constructor.

File

src/WebformSubmissionForm.php, line 2561

Class

WebformSubmissionForm
Provides a webform to collect and edit submissions.

Namespace

Drupal\webform

Code

protected function alterElementsForm(array &$elements, array &$form, FormStateInterface $form_state) {
  foreach ($elements as $key => &$element) {
    if (!WebformElementHelper::isElement($element, $key)) {
      continue;
    }
    $element_plugin = $this->elementManager
      ->getElementInstance($element);
    if ($element_plugin) {
      $element_plugin
        ->alterForm($element, $form, $form_state);
    }

    // Recurse and alter nested elements forms.
    $this
      ->alterElementsForm($element, $form, $form_state);
  }
}