I want to modify the behaviour of an Angular form.
The answer to question 4700 tells me 'how' to do it (add some JavaScript), but I'm interested in 'where' to do it.
If it was a PHP form I could use a hook. Should I use an extension?
CiviCRM Stack Exchange is a question and answer site for administrators and users of the CiviCRM Constituent Relationship Management software. It only takes a minute to sign up.
Sign up to join this communityI want to modify the behaviour of an Angular form.
The answer to question 4700 tells me 'how' to do it (add some JavaScript), but I'm interested in 'where' to do it.
If it was a PHP form I could use a hook. Should I use an extension?
I usually do it in an extension. This allows me to enable/disable changes at will.
In the main extension file (eg [ext_dir]/com.example.myextension/myextension.php) add this hook. I think its called on all pages and forms -- may have to use pageRun or alterContent.
function myextension_civicrm_alterTemplateFile($formName, &$form, $context, &$tplName) {
$resource = CRM_Core_Resources::singleton();
if ($formName=='theFormToEdit') {
$resource->addScriptFile('com.example.myextension', 'js/mychanges.js');
}
}