function makemeeting_field_presave in Make Meeting Scheduler 7.2
Implements hook_field_presave().
File
- ./
makemeeting.field.inc, line 475 - This file is mostly about the field configuration.
Code
function makemeeting_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
if ($field['type'] == 'makemeeting') {
foreach ($items as $delta => $item) {
if (isset($item['choices'])) {
// Sort the choices by date
$choices = array_values($item['choices']);
usort($choices, '_makemeeting_sort_choices');
// Affect timestamp as keys
$timestamped_choices = array();
foreach ($choices as $choice) {
$dateTime = _makemeeting_date_timestamp($choice['chdate']);
$timestamped_choices[$dateTime
->format('d-m-Y')] = $choice;
}
// Serialize the whole array
$items[$delta]['choices'] = serialize($timestamped_choices);
}
}
}
}