2 * Implements hook_field_widget_properties_alter().
4 function {{ machine_name }}_field_widget_properties_alter(&$widget, $context) {
5 // Change a widget's type according to the time of day.
6 $field = $context['field'];
7 if ($context['entity_type'] == 'node' && $field['field_name'] == 'field_foo') {
9 $widget['type'] = $time < 12 ? 'widget_am' : 'widget_pm';