You are here

function email_field in Email Field 6

Implementation of hook_field().

File

./email.module, line 58

Code

function email_field($op, &$node, $field, &$items, $teaser, $page) {
  switch ($op) {
    case 'validate':
      if (is_array($items)) {
        foreach ($items as $delta => $item) {
          if ($item['email'] != '' && !valid_email_address(trim($item['email']))) {
            form_set_error($field['field_name'], t('"%mail" is not a valid email address', array(
              '%mail' => $item['email'],
            )));
          }
        }
      }
      break;
    case 'sanitize':
      foreach ($items as $delta => $item) {
        $items[$delta]['safe'] = check_plain($item['email']);
      }
      break;
  }
}