You are here

function mailchimp_lists_field_validate in Mailchimp 7.3

Same name and namespace in other branches
  1. 7.5 modules/mailchimp_lists/includes/mailchimp_lists.field.inc \mailchimp_lists_field_validate()
  2. 7.4 modules/mailchimp_lists/includes/mailchimp_lists.field.inc \mailchimp_lists_field_validate()

Implements hook_field_validate().

File

modules/mailchimp_lists/includes/mailchimp_lists.field.inc, line 287
Field hooks.

Code

function mailchimp_lists_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
  if ($instance['required'] && $entity !== NULL) {
    foreach ($items as $delta => $item) {
      if (!$item['subscribe']) {
        $errors[$field['field_name']][$langcode][$delta][] = array(
          'error' => 'mailchimp_lists_required',
          'message' => t('Subscription to MailChimp List %name is required.', array(
            '%name' => $instance['label'],
          )),
        );
        return FALSE;
      }
    }
  }
  return TRUE;
}