I need to customize the fields of a form inside a dialog popup from within an extention. The common form hooks obviously don't work here because I can't address code that's loaded dynamically. Is there a way to inject JavaScript code to the AJAX snippet of a dialog e.g. new case form?

1 Answer 1


The buildForm hook works for popups too.

TIP: put some logging in a buildForm hook to log the $formName, then visit the page you're interested in.

If you're interested in new case, see https://lab.civicrm.org/extensions/opencaserearranger for one example.

  • form.getTemplate().fetchWith() and addScript() were the missing pieces. Thank you!
    – Jan
    Commented Apr 10 at 6:40

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.