You are here

function link_field in Link 6

Same name and namespace in other branches
  1. 5 link.module \link_field()
  2. 6.2 link.module \link_field()

Implementation of hook_field().

File

./link.module, line 179
Defines simple link field types.

Code

function link_field($op, &$node, $field, &$items, $teaser, $page) {
  switch ($op) {
    case 'load':
      foreach ($items as $delta => $item) {
        _link_load($items[$delta], $delta);
      }
      break;
    case 'validate':
      $optional_field_found = FALSE;
      foreach ($items as $delta => $value) {
        _link_validate($items[$delta], $delta, $field, $node, $optional_field_found);
      }
      if ($field['url'] == 'optional' && $field['title'] == 'optional' && $field['required'] && !$optional_field_found) {
        form_set_error($field['field_name'] . '][0][title', t('At least one title or URL must be entered.'));
      }
      break;
    case 'presave':
      foreach ($items as $delta => $value) {
        _link_process($items[$delta], $delta, $field, $node);
      }
      break;
    case 'sanitize':
      foreach ($items as $delta => $value) {
        _link_sanitize($items[$delta], $delta, $field, $node);
      }
      break;
  }
}