function context_field_field_load in Context Field 7
Implements hook_field_load().
We need to set the context if we are using the use default widget
File
- ./
context_field.module, line 457 - Context Field
Code
function context_field_field_load($entity_type, &$entities, $field, $instances, $langcode, &$items, $age) {
foreach ($instances as $instance) {
switch ($instance['widget']['type']) {
// If we are using the default context set it now
case 'context_field_default':
foreach ($items as $id => $item) {
if (empty($instance['widget']['settings']['form_element']['user_toggle']) || !empty($items[$id][0]['context'])) {
$context = $instance['settings']['default_context'];
$items[$id] = array(
0 => array(
'context' => $context,
),
);
}
else {
$items[$id] = array(
0 => array(
'context' => FALSE,
),
);
}
}
break;
}
}
}