[MGNLUI-4086] Add option to set 'now' as the default value for a date field Created: 24/Nov/16  Updated: 28/Jun/17  Resolved: 19/Jun/17

Status: Closed
Project: Magnolia UI
Component/s: forms
Affects Version/s: None
Fix Version/s: 5.5.5

Type: Improvement Priority: Neutral
Reporter: Nils Breunese Assignee: Sang Ngo Huu
Resolution: Fixed Votes: 2
Labels: quickwin, usability, ux
Remaining Estimate: 0d
Time Spent: 2d
Original Estimate: 2d

Issue Links:
duplicate
relation
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Documentation update required:
Yes
Date of First Response:
Sprint: Saigon 100, Saigon 101
Story Points: 3

 Description   

We have multiple use cases where it would be nice to have the option to set the default value of a date field to the current date/time (the moment the dialog field is instantiated). Now editors need to click the calendar, which does pre-select the current date, but it would be great if that wasn't required and the current date would just be pre-filled in the field when the field configuration says so.



 Comments   
Comment by Antti Hietala [ 08/Jun/17 ]

Same request in a comment on Date field documentation:

Have you guys thought about putting in a simple property to allow the date field's value to be pre-filled with the current date/time when they arrive to the dialog?

Comment by Antti Hietala [ 08/Jun/17 ]

Vaadin DateField documentation shows an example of setting date/time to now:

// Create a DateField with the default style
DateField date = new DateField();

// Set the date to present
date.setValue(LocalDate.now());
Comment by Richard Gange [ 08/Jun/17 ]

I think it probably makes the most sense to use the defaultValue property provided by ConfiguredFieldDefinition. But we need to probably provide a list of values or a format that we expect there. For example if the word "now" is there then that would trigger date.setValue(LocalDate.now());.

Generated at Mon Feb 12 09:13:08 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.