Skip to content

Commit

Permalink
GetDKAN#4051: Flexible DateTime widget: Small UX improvement when cle…
Browse files Browse the repository at this point in the history
…aring date
  • Loading branch information
stefan-korn committed Nov 7, 2023
1 parent d80a091 commit 0531552
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/json_form_widget/src/Element/FlexibleDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
if (!empty($input['date']) && empty($input['time'])) {
$input['time'] = '00:00:00';
}
if ($element['#date_date_element'] !== 'none' && empty($input['date'])) {
if ($input['time'] === '00:00:00') {
unset($input['time']);
}
}
return parent::valueCallback($element, $input, $form_state);
}

Expand Down

0 comments on commit 0531552

Please sign in to comment.