You are here

public function WebformSubmissionForm::afterBuild in Webform 8.5

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

Form element #after_build callback: Updates the entity with submitted data.

Updates the internal $this->entity object with submitted values when the form is being rebuilt (e.g. submitted via AJAX), so that subsequent processing (e.g. AJAX callbacks) can rely on it.

Overrides EntityForm::afterBuild

File

src/WebformSubmissionForm.php, line 1286

Class

WebformSubmissionForm
Provides a webform to collect and edit submissions.

Namespace

Drupal\webform

Code

public function afterBuild(array $form, FormStateInterface $form_state) {

  // If webform has a custom #action remove Form API fields.
  // @see \Drupal\Core\Form\FormBuilder::prepareForm
  if (strpos($form['#action'], 'form_action_') === FALSE) {

    // Remove 'op' #name from all action buttons.
    foreach (Element::children($form['actions']) as $child_key) {
      unset($form['actions'][$child_key]['#name']);
    }
    unset($form['form_build_id'], $form['form_token'], $form['form_id']);
  }
  return $form;
}