function merci_hours_quickset_field_options in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3
1 call to merci_hours_quickset_field_options()
- merci_hours_quickset_field_widget_form_alter in merci_hours/
merci_hours_quickset.module - * Implements hook_field_widget_form_alter(). * * For date fields with work calendar settings, * pass the configuration into the (date_combo) element. * * We are copying settings from instance settings to leaf form * elements in cascade, since we are…
File
- merci_hours/
merci_hours_quickset.module, line 87
Code
function merci_hours_quickset_field_options($context) {
$field_name = $context['instance']['field_name'];
$entity_type = $context['instance']['entity_type'];
$bundle = $context['instance']['bundle'];
if ($cached = cache_get("merci_quickset_field_options:{$field_name}:{$entity_type}:{$bundle}")) {
return $cached->data;
}
$options = array();
$settings = $context['instance']['settings']['merci_hours'];
$wc = merci_hours_instantiate($settings['id']);
$wrapper = entity_metadata_wrapper('merci_hours', $wc);
foreach ($settings['quickset_fields'] as $field_name) {
$field_info = field_info_instance('merci_hours', $field_name, 'merci_hours');
$value = $wrapper->{$field_name}
->value();
$options[$value] = $field_info['label'];
}
cache_set("merci_quickset_field_options:{$field_name}:{$entity_type}:{$bundle}", $options);
return $options;
}