Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 3.1.5
-
Fix Version/s: 3.2.1
-
Component/s: Core CiviCRM
-
Labels:None
Description
In the Contact Edit Form, If a custom data group contains a date field (i.e., html_type = 'Select Date'), and the field is NULL in its custom data value field in the database, CiviCRM will unhelpfully reset the the empty field to today's date.
The actual reset occurs in CRM_Utils_Date::setDateDefaults(), which assumes that an empty field should always be reset to today's date. Because users will not often see all of the date fields in the edit form (many are in closed fieldsets), on save, the empty fields will be refilled with today's date.
CRM_Utils_Date::setDateDefaults() is called a fair bit (I count 64 times in CRM/ ), so a fix probably isn't trivial. But I would guess that the call needs to get a bit of context from the caller, so it knows whether it is looking at an Add or an Edit. It might also help if date fields had some additional UI to control default behavior for this, rather than simply assume today's date; the function is too low level to make this decision IMO.
Work around is to use hook_civicrm_buildForm, and reset the value of any interesting form fields