1

The QuickForm.php file that I want to override is located in civicrm/packages/HTML/Quickform. I set my override directory to [civicrm.files]/override_php and put a copy of the originale file in override directory/packages/HTML/Quickform.

  1. Is the location correct?

This file define the class HTML_QuickForm and I added a new method call getElements(). The class HTML_QuickForm_Page extend this class which is then extended again to define CRM_Core_Form. 2. Is my modified HTML_QuickForm class going to be use to extend the descending class or do I need to override (have a copy in my override directory) every descending down to CRM_Core_Form to make it happen. 3. Should I just override CRM_Core_Form even if the method does not make much sense in the context of CRM_Core_Form?

Here are my modifications:

 function &getElements()
{
    if (isset($this->_elements)) {
        return $this->_elements[];
    } else {
        $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elements' does not exist in HTML_QuickForm::getElements()", 'HTML_QuickForm_Error', true);
        return $error;
    }
}

Current error message is : undefined method getElements when I try to get the elements array in a buildForm hook.

Thank for your help

1 Answer 1

0

If you really want to do this you would just override CRM_Core_Form, but what is it you're really trying to do because overriding anything is going to cause upgrade problems. My guess is you're really trying to do something that would be better done by implementing the buildForm hook: https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/

2
  • Thanks for your reply. I am well aware off the pitfall of overriding core material. I would really like to understand why my attempt at this is failing. By the way, during my research, I went across a civicrm extension that help you manage your overring files, being php or tpl. I not sure exactly what are the functions provided to help with the "management" of overrides.
    – Syxys
    Commented Jun 8 at 12:17
  • It works for me but you need to put Quickform.php in "override directory/packages/HTML" not "override directory/packages/HTML/Quickform"
    – Demerit
    Commented Jun 8 at 15:41

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.