function datetimehideseconds_field_widget_form_alter in DateTime hide Seconds 8
Implements hook_field_widget_form_alter().
File
- ./
datetimehideseconds.module, line 37
Code
function datetimehideseconds_field_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
/** @var \Drupal\Core\Field\WidgetInterface $widget */
$widget = $context['widget'];
if ($widget
->getThirdPartySetting('datetimehideseconds', 'hide')) {
$element['value']['#datetimehideseconds']['hide'] = TRUE;
if (isset($element['end_value'])) {
$element['end_value']['#datetimehideseconds']['hide'] = TRUE;
}
}
}