[MGNLUI-4270] DateField: Default value is not picked up on existing (but empty) field Created: 18/Aug/17  Updated: 13/Sep/17  Resolved: 13/Sep/17

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

Type: Bug Priority: Major
Reporter: Christian Ringele Assignee: Unassigned
Resolution: Not an issue Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
relates to MGNLUI-4271 DateField: default value can not be s... Closed
causality
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)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Situation:
The component exists with a DateField in its dialog. But the field value is empty (for example a new added field or never chosen a date to store). So there exists no correlating property.

Result:
The method info.magnolia.ui.form.field.factory.DateFieldFactory.getConfiguredDefaultValue() is never called.

Reason:
In the method
{{info.magnolia.ui.form.field.factory.AbstractFieldFactory.setPropertyDataSourceAndDefaultValue(Property)}
the boolean expression ((ItemAdapter) item).isNew() is returning false.



 Comments   
Comment by Antti Hietala [ 07/Sep/17 ]

cringele, the defaultValue only applies to new items. For example, if you have an existing tour and you add a date field into the dialog the tour will not get a default date. But create a completely new tour and it will get the default.

If you want to add default values to existing items you need to populate them with a Groovy script or set a custom transformer on the field that always sets a default value when the user opens the dialog.

Comment by Christian Ringele [ 13/Sep/17 ]

ahietala Ahh I see, so summarised the rational of this behaviour is:
When a component exists, the field should never display a default value. Otherwise the Author can not know if the displayed value is a stored value, or just a proposed default value not saved yet.
Is this right? if so I completely agree with it.

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