function entity_metadata_field_property_set in Entity API 7
Callback for setting field property values.
1 string reference to 'entity_metadata_field_property_set'
- entity_metadata_field_default_property_callback in modules/
field.info.inc - Callback to add in property info defaults per field instance.
File
- modules/
callbacks.inc, line 465 - Provides various callbacks for the whole core module integration.
Code
function entity_metadata_field_property_set($entity, $name, $value, $langcode, $entity_type, $info) {
$field = field_info_field($name);
$columns = array_keys($field['columns']);
$langcode = entity_metadata_field_get_language($entity_type, $entity, $field, $langcode);
$values = $field['cardinality'] == 1 ? array(
$value,
) : (array) $value;
$items = array();
foreach ($values as $delta => $value) {
if (isset($value)) {
$items[$delta][$columns[0]] = $value;
if ($info['type'] == 'boolean' || $info['type'] == 'list<boolean>') {
// Convert boolean values back to an integer for writing.
$items[$delta][$columns[0]] = (int) ($items[$delta][$columns[0]] = $value);
}
}
}
$entity->{$name}[$langcode] = $items;
// Empty the static field language cache, so the field system picks up any
// possible new languages.
drupal_static_reset('field_language');
}