Monthly Archives: August 2012

How to make a field required in CiviCRM

$form->addRule(); Here’s an example from the hook_civicrm_buildForm() function in a custom module we’ve been working on. if ($formName == ‘CRM_Contribute_Form_Contribution’) { $form->addRule(‘receive_date’, ts(‘This field is required.’), ‘required’, NULL, NULL, NULL, TRUE); $form->addRule(‘contribution_page_id’,  ts(‘This field is required.’), ‘required’, NULL, NULL, NULL,

Posted in CiviCRM