function commerce_file_field_entity_metadata_validate_item in Commerce File 7
Callback for validating commerce_file field $items.
- Requires 'fid' to be a valid file
- Allows 'data' to be optional
See also
entity_metadata_field_file_validate_item()
1 string reference to 'commerce_file_field_entity_metadata_validate_item'
- commerce_file_field_property_info_callback in includes/
commerce_file.field.inc - Callback to alter the property info of price fields.
File
- includes/
commerce_file.field.inc, line 666 - Implement an commerce_file field, based on the file module's file field.
Code
function commerce_file_field_entity_metadata_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;
}
}
return TRUE;
}