function fraction_field_load in Fraction 7
Implements hook_field_load().
File
- ./
fraction.field.inc, line 483 - Fraction Field API functions
Code
function fraction_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
// Iterate through entities and their items.
foreach ($entities as $id => $entity) {
foreach ($items[$id] as $delta => $item) {
// Load the numerator and denominator values.
$numerator = $items[$id][$delta]['numerator'];
$denominator = $items[$id][$delta]['denominator'];
// Create a new Fraction object and add it to the field.
$fraction = fraction($numerator, $denominator);
$items[$id][$delta]['fraction'] = fraction($numerator, $denominator);
// Calculate the decimal value of the fraction.
$items[$id][$delta]['decimal'] = $fraction
->toDecimal(0, TRUE);
}
}
}