How does one add a default value in one of Datepicker fields while adding or editing Relationship? For example, set today's date as a start date at Enabled checkbox check and as the end date if un-checked. Should it be a custom piece of jQuery code or it's better to alter jcalendar.tpl? If latter, how one defines "Add/Edit Relationship" modal frame has been triggered and not, say, "Add/Edit Membership?" one.

1 Answer 1


You can set a datepicker's default value in the setDefaultValues() method of the form. Here is a snippet of code that sets a date to today if none exists, and to a saved date if it does:

    if (empty($data['thank_you_date'])) {
      $defaultValues['thank_you_date'] = date('Y-m-d');
    } else {
      $defaultValues['thank_you_date'] = $data['thank_you_date'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.