Skip to content

Commit

Permalink
Reroll #4051: Flexible DateTime widget: Small UX improvement when cle…
Browse files Browse the repository at this point in the history
…aring date (#4157)

Co-authored-by: Stefan Korn <drupal@stefan-korn.de>
  • Loading branch information
dafeder and stefan-korn committed Apr 9, 2024
1 parent cd39b31 commit 17c34df
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 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,13 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
if (!empty($input['date']) && empty($input['time'])) {
$input['time'] = '00:00:00';
}
if (
($input['time'] ?? NULL === '00:00:00')
&& $element['#date_date_element'] !== 'none'
&& empty($input['date'])
) {
unset($input['time']);
}
return parent::valueCallback($element, $input, $form_state);
}

Expand Down

0 comments on commit 17c34df

Please sign in to comment.