Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-19911

Date problem in profile edit Custom date field

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.15
    • Fix Version/s: 4.7.19
    • Component/s: CiviCRM Profile
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding
    • Verified?:
      No

      Description

      When a custom date field is used in a profile and the profile is edited, the existing date is not shown.

      The current code in js/Common.js updateInputFields() sets the datepicker date as follows:

      $dateField.datepicker('setDate', _.includes(val, '-') ? $.datepicker.parseDate('yy-mm-dd', val) : null);
      

      When editing the field at the CiviCRM contact screen, val is set as eg 2017-02-28 00:00:00 and it works OK. However when used in a profile edit, the field looks like 02/28/2017 and so doesn't work.

      CRM\Utils\Date.php :: setDateDefaults() deliberately sets the $dateFormat = 'm/d/Y';

      I repeated the problem at a demo site: creating a new field and profile, then creating a new user and editing the field at the contact screen and by editing the profile, ie today:

      https://demo.circle-interactive.co.uk/civicrm/contact/view?reset=1&cid=214

      https://demo.circle-interactive.co.uk/civicrm/profile/edit?reset=1&gid=14&id=214

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              chriscant Chris Cant
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: