1 link.module | _link_process(&$item, $delta, $field, $entity) |
Prepares the item attributes and URL for storage.
File
- core/
modules/ link/ link.module, line 422 - Defines simple link field types.
Code
function _link_process(&$item, $delta, $field, $entity) {
// Trim whitespace from URL.
if (!empty($item['url'])) {
$item['url'] = trim($item['url']);
}
// If no attributes are set then make sure $item['attributes'] is an empty
// array, so $field['attributes'] can override it.
if (empty($item['attributes'])) {
$item['attributes'] = array();
}
// Serialize the attributes array.
if (!is_string($item['attributes'])) {
$item['attributes'] = serialize($item['attributes']);
}
// Don't save an invalid default value (e.g. 'http://').
if ((isset($field['widget']['default_value'][$delta]['url']) && $item['url'] == $field['widget']['default_value'][$delta]['url']) && is_object($entity)) {
if (!link_validate_url($item['url'])) {
unset($item['url']);
}
}
}