function link_field_presave

Implements hook_field_presave().

File

drupal/core/modules/field/modules/link/link.module, line 82
Defines simple link field types.

Code

function link_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  foreach ($items as $delta => &$item) {

    // Trim any spaces around the URL and title.
    $item['url'] = trim($item['url']);
    $item['title'] = trim($item['title']);

    // Serialize the attributes array.
    $item['attributes'] = !empty($item['attributes']) ? serialize($item['attributes']) : NULL;
  }
}