You are here

function simplenews_subscriptions_admin_form_validate in Simplenews 7

Same name and namespace in other branches
  1. 6.2 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form_validate()
  2. 7.2 includes/simplenews.subscription.inc \simplenews_subscriptions_admin_form_validate()

FAPI ADMIN subscription form_validate.

1 string reference to 'simplenews_subscriptions_admin_form_validate'
simplenews_subscriptions_admin_form in includes/simplenews.subscription.inc
FAPI ADMIN subscription form.

File

includes/simplenews.subscription.inc, line 802
(Un)subscription and (un)subscription confirmation

Code

function simplenews_subscriptions_admin_form_validate($form, &$form_state) {
  $subscriber = simplenews_subscriber_load_by_mail($form_state['values']['mail']);
  $valid_email = valid_email_address($form_state['values']['mail']);
  if (!$valid_email) {
    form_set_error('mail', t('The e-mail address you supplied is not valid.'));
  }
  $checked_newsletters = array_filter($form_state['values']['newsletters']);
  if (!count($checked_newsletters) && !$subscriber) {
    form_set_error('newsletters', t('You must select at least one newsletter.'));
  }
  $languages = language_list('enabled');
  if (!empty($form_state['values']['language']) && !isset($languages[1][$form_state['values']['language']])) {
    form_set_error('language', t('Please choose a language from the list.'));
  }
}