You are here

public function EmailWebformHandler::validateConfigurationForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformHandler/EmailWebformHandler.php \Drupal\webform\Plugin\WebformHandler\EmailWebformHandler::validateConfigurationForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Overrides WebformHandlerBase::validateConfigurationForm

1 call to EmailWebformHandler::validateConfigurationForm()
ScheduleEmailWebformHandler::validateConfigurationForm in modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
Form validation handler.
1 method overrides EmailWebformHandler::validateConfigurationForm()
ScheduleEmailWebformHandler::validateConfigurationForm in modules/webform_scheduled_email/src/Plugin/WebformHandler/ScheduleEmailWebformHandler.php
Form validation handler.

File

src/Plugin/WebformHandler/EmailWebformHandler.php, line 842

Class

EmailWebformHandler
Emails a webform submission.

Namespace

Drupal\webform\Plugin\WebformHandler

Code

public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  parent::validateConfigurationForm($form, $form_state);
  $values = $form_state
    ->getValues();

  // Set custom body based on the selected format.
  $values['twig'] = FALSE;
  switch ($values['body']) {
    case 'twig':
      $values['body'] = $values['body_custom_twig'];
      $values['twig'] = TRUE;
      break;
    case WebformSelectOther::OTHER_OPTION:
      $body_format = $values['html'] ? 'html' : 'text';
      $values['body'] = $values['body_custom_' . $body_format];
      break;
  }
  $form_state
    ->setValues($values);
  $this
    ->applyFormStateToConfiguration($form_state);
}