You are here

function datetimehideseconds_field_widget_third_party_settings_form in DateTime hide Seconds 8

Implements hook_field_widget_third_party_settings_form().

File

./datetimehideseconds.module, line 51

Code

function datetimehideseconds_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $widget, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $element = [];
  if ($widget instanceof DateTimeWidgetBase) {
    $element['hide'] = [
      '#type' => 'checkbox',
      '#title' => t('Hide seconds'),
      '#description' => t('This will have no effect if there is no time widget.'),
      '#default_value' => $widget
        ->getThirdPartySetting('datetimehideseconds', 'hide'),
    ];
  }
  return $element;
}