I added a text element to a New Event
page using buildForm hook.
function mymodule_civicrm_buildForm($formName, &$form) {
if ('CRM_Event_Form_ManageEvent_EventInfo' == $formName) {
$form->add('text', 'custom_element', ts('Custom Element Label));
CRM_Core_Region::instance('page-body')->add(array(
'template' => 'CustomElement.tpl',
));
}
}
And I added a validation code using validateForm hook which looks like this:
function mymodule_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {
if ('CRM_Event_Form_ManageEvent_EventInfo' == $formName) {
if ( validation condition fails )
$form->_errors['custom_element'] = 'Validation message';
}
}
}
But when validation fails, let alone error, the text element is not shown at all. How do I get it to show both the element and the error on the element?