Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CiviCRM - implementation of hook_civicrm_buildForm() to remove required billing address fields.
/**
* Implements hook_civicrm_buildForm().
*/
function example_civicrm_buildForm($formName, &$form) {
switch ($formName) {
case 'CRM_Contribute_Form_Contribution_Main':
$fields_not_required = array(
'billing_first_name',
'billing_middle_name',
'billing_last_name',
'billing_street_address-5',
'billing_city-5',
'billing_state_province_id-5',
'billing_postal_code-5',
'billing_country_id-5',
);
foreach ($fields_not_required as $field) {
$form->_paymentFields[$field]['is_required'] = FALSE;
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment