function date_field_widget_properties_alter in Date 7.2
Same name and namespace in other branches
- 7.3 date.module \date_field_widget_properties_alter()
Implements hook_field_widget_properties_alter().
File
- ./
date.module, line 844
Code
function date_field_widget_properties_alter(array &$widget, $context) {
// Alters the widget properties of a field instance before it gets displayed.
// Used here to flag new entities so we can later tell if they need default
// values.
if (in_array($widget['type'], array(
'date_select',
'date_text',
'date_popup',
))) {
$entity_type = $context['entity_type'];
$entity = $context['entity'];
$info = entity_get_info($entity_type);
$id = $info['entity keys']['id'];
$widget['is_new'] = FALSE;
if (empty($entity->{$id})) {
$widget['is_new'] = TRUE;
}
}
}