View Issue Details

IDProjectCategoryView StatusLast Update
0027914mantisbtcustom fieldspublic2021-02-15 17:18
Reporteraaribaud Assigned Todregad  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.24.4 
Target Version2.25.0Fixed in Version2.25.0 
Summary0027914: Custom date field with default value left blank even when field is required
Description

When a custom date field is configured to:

  • have a default value (e.g., {today}';
  • be neither displayed nor required at creation time,
  • be displayed and required at resolution time,

then:

  • when the bug is created, the custom field is left unset (default not applied),
  • but when advancing the bug status to "resolved", the custom date field default is not applied either, leaving the field unset, which is an illegal value as the field is required, but will only be flagged as such when validating the form.
  • the current date must be entered manually.
Steps To Reproduce

Create a custom date field with a default of '{today}'
Set it to neither be displayed nor be required for creation
Set it to be displayed and required for resolution
Add the field to a project
Create a new bug for the project
(optionally, check that the database does not record a value for this field and this bug)
Advance the bug to resolution
Notice the custom field is empty.
Validate the form.
The form is rejected because an empty date is not valid for a required custom date field.

Additional Information

The most sensible fix would be to compute and apply the default value for a custom date field, not only on creation, but also on updates or status changes if the field is still unset but has become required.

TagsNo tags attached.

Activities

aaribaud

aaribaud

2021-01-26 04:13

reporter   ~0065037

Last edited: 2021-02-04 13:07

After some testing with ticket workflow and digging in the database, I get to the following conclusions:

  • if a custom date field has a default value and is configured to be shown on issue creation, then it is set to its default value;
  • if a custom date field has a default value but is not configured to be shown on issue creation, then it is left unset (the default value is not applied);
  • if a custom date field is unset but must be displayed when e.g. updating the issue, then the field is displayed empty, and if left unchanged, will remain unset;
  • if a custom date field is required, then the user must set the field to some valid date in order for the issue update to be allowed.

The combination of the above results in the following: if an unset custom date field (due to 2) must be displayed and is required, then it will be displayed empty (due to 3) but that empty value won't be allowed (due to 4). In that precise case, I think it would make sense to apply the default value regardless of the ticket state, before displaying the field.

atrol

atrol

2021-01-26 07:23

developer   ~0065039

PR https://github.com/mantisbt/mantisbt/pull/1734

Related Changesets

MantisBT: master 9d6e1de9

2021-01-19 05:32:54

aaribaud


Committer: dregad Details Diff
Apply default value for required but unset custom date fields

When updating or changing the state of an issue, if a custom date field is
required yet unset but has a default value, then pre-fill the field with
the default value instead of leaving it blank.

Fixes 0027914

Signed-off-by: Albert ARIBAUD <albert.aribaud@free.fr>
Affected Issues
0027914
mod - core/custom_field_api.php Diff File