You are here

function webform_email_edit_form_validate in Webform 7.4

Same name and namespace in other branches
  1. 6.3 includes/webform.emails.inc \webform_email_edit_form_validate()
  2. 7.3 includes/webform.emails.inc \webform_email_edit_form_validate()

Validate handler for webform_email_edit_form().

1 string reference to 'webform_email_edit_form_validate'
webform_email_edit_form in includes/webform.emails.inc
Form for configuring an e-mail setting and template.

File

includes/webform.emails.inc, line 519
Provides interface and database handling for e-mail settings of a webform.

Code

function webform_email_edit_form_validate($form, &$form_state) {
  if ($form_state['values']['from_address_option'] == 'custom') {
    webform_email_validate($form_state['values']['from_address_custom'], 'from_address_custom', FALSE, FALSE, TRUE);
  }

  // Validate component-based values for the TO and FROM address.
  foreach (array(
    'email',
    'from_address',
  ) as $field_name) {
    if ($form_state['values'][$field_name . '_option'] == 'component') {
      $cid = $form_state['values'][$field_name . '_component'];
      if (isset($form_state['values'][$field_name . '_mapping'][$cid])) {
        $empty_allowed = $field_name === 'email';
        $multiple_allowed = $field_name === 'email';
        foreach ($form_state['values'][$field_name . '_mapping'][$cid] as $key => &$value) {
          webform_email_validate($value, "{$field_name}_mapping][{$cid}][{$key}", $empty_allowed, $multiple_allowed, TRUE);
        }
      }
    }
  }
}