Provides field_get_value(), field_get_values(), and field_set_values() functions for developer and themer use.
Developers and themers expect to constantly type some form of $entity->field_data['und'][0]['value']; throughout site customization modules and themes. It gets tedious, the code can be difficult to read, and you find yourself staring at the output of devel's dsm() far too much.
Install this and you can use field_get_value($entity, 'data'); Note the missing 'field_' name prefix, it is automatically added as needed. Multi-value fields are converted to/from standard arrays, which can save a lot of array processing code. field_set_values() accepts values or arrays, so field_set_value() would be redundant. Note: Fields with multiple columns should be accessed with field_get_items().
<?php
//This "get value" code:
print $entity->field_data['und'][0]['value'];
//Becomes:
print field_get_value($entity, 'data');
//This "get values" code:
foreach ($entity->field_data['und'] as $value) {
print $value['value'];
}
//Or this "get values using field_get_items" code:
$items = field_get_items('node', $entity, 'field_data');
foreach ($items as $value) {
print $value['value'];
}
//Becomes:
$values = field_get_values($entity, 'data');
foreach ($values as $value) {
print $value;
}