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

Can't set default value via URL query string, for custom date fields


    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.17, 4.7.22
    • Fix Version/s: 5.3
    • Component/s: Core CiviCRM
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
    • Funding Source:
      Contributed Code
    • Verified?:


      There's not much documentation for it, but for a long time CiviCRM has supported the setting of field values by using URL query parameters. But since 4.7.17 at least (perhaps earlier), this doesn't work for fields with a date picker, though it still works for other fields.

      Example URL: http://my.example.com/civicrm/contribute/transact?reset=1&id=5&custom_20=06/06/2017&price_37=20  This should set the custom date field ("custom_20") to a default value of '06/06/2017', and the "other amount" field ("price_37") to a default of "20".  For the price field it works fine, but the date field remains blank. Note this image:

      Interesting details:

      • The date picker field is not the "real" field, and it turns out the "real" field is just hidden and then populated by the date picker.
      • The "real" field actually does get the correct value from the query parameter, as shown in this image, where I've removed the "{display:none}" styling to display the "real" field:


      This appears to be the same issue as CRM-18349, in which the date value must be ISO formatted before being set as a default value for crmDatepicker custom field.

      PR forthcoming.


        1. date_blank.png
          35 kB
          Allen Shaw
        2. date_real.png
          36 kB
          Allen Shaw



            • Assignee:
              allenshaw Allen Shaw
              allenshaw Allen Shaw
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: