Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function update_settings_validate

Form validation handler for update_settings().

Validates the e-mail addresses and ensures the field is formatted correctly.

See also

update_settings_submit()

1 string reference to 'update_settings_validate'
update_settings in modules/update/update.settings.inc
Form constructor for the update settings form.

File

modules/update/update.settings.inc, line 70

Code

function update_settings_validate ($form, &$form_state) {
 if (!empty($form_state['values']['update_notify_emails'])) {
 $valid = array();
 $invalid = array();
 foreach (explode ("\n", trim ($form_state['values']['update_notify_emails'])) as $email) {
 $email = trim ($email);
 if (!empty($email)) {
 if (valid_email_address ($email)) {
 $valid[] = $email;
 }
 else {
 $invalid[] = $email;
 }
 }
 }
 if (empty($invalid)) {
 $form_state['notify_emails'] = $valid;
 }
 elseif (count ($invalid) == 1) {
 form_set_error ('update_notify_emails', t ('%email is not a valid e-mail address.', array(
 '%email' => reset ($invalid),
 )));
 }
 else {
 form_set_error ('update_notify_emails', t ('%emails are not valid e-mail addresses.', array(
 '%emails' => implode (', ', $invalid),
 )));
 }
 }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.