function entity_metadata_field_file_validate_item in Entity API 7
Callback for validating file field $items.
1 string reference to 'entity_metadata_field_file_validate_item'
- entity_metadata_field_file_callback in modules/
field.info.inc - Additional callback to adapt the property info for file fields.
File
- modules/
callbacks.inc, line 640 - Provides various callbacks for the whole core module integration.
Code
function entity_metadata_field_file_validate_item($items, $context) {
// Allow NULL values.
if (!isset($items)) {
return TRUE;
}
// Stream-line $items for multiple vs non-multiple fields.
$items = !entity_property_list_extract_type($context['type']) ? array(
$items,
) : (array) $items;
foreach ($items as $item) {
// File-field items require a valid file.
if (!isset($item['fid']) || !file_load($item['fid'])) {
return FALSE;
}
if (isset($context['property info']['display']) && !isset($item['display'])) {
return FALSE;
}
}
return TRUE;
}