I have a created a custom group and a custom field within that group.

One of the Custom fields is Date.

Is there any way to autoload 'current date' (today) in the default value field Using a hook or something?

I have been googling but i am not getting any results.


1 Answer 1


I did this by using CiviCRM hooks (BuildForm).

($form == CRM_Core_Action::ADD) {
        $currentDate = date('d/m/Y');
        for ($i = 1; $i < 10000; $i++) {
            $defaults['custom_197_-' . $i] = $currentDate;
            $form->updateElementAttr('custom_197_-'. $i,array('readonly'));

This is working

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.