I'm trying to add a couple of fields to the message templates ("CRM_Admin_Form_MessageTemplates") in a custom extension. I use the "buildForm", "validateForm" and the "postProcess" hooks. The "buildForm" and the "validateForm" hooks works perfectly but the "postProcess" hook does nothing. I'm using civicrm 5.27.4 and drupal 7.72. I tried it also on a other installation but same results. I also tried it with a other clean custom extension but that also doesn't work. And the same hook works on other forms. Can someone help me?
1 Answer
Yes, some admin config forms doesn't invoke postProcess hook. Try below patch to invoke post process hook
diff --git a/CRM/Admin/Form/MessageTemplates.php b/CRM/Admin/Form/MessageTemplates.php
index 5f809f2..67cac30 100644
--- a/CRM/Admin/Form/MessageTemplates.php
+++ b/CRM/Admin/Form/MessageTemplates.php
@@ -309,6 +309,7 @@ class CRM_Admin_Form_MessageTemplates extends CRM_Core_Form {
}
$messageTemplate = MessageTemplate::save()->setDefaults($params)->setRecords([['id' => $this->_id]])->execute()->first();
+ $this->postProcessHook();
CRM_Core_Session::setStatus(ts('The Message Template \'%1\' has been saved.', [1 => $messageTemplate['msg_title']]), ts('Saved'), 'success');
if (isset($this->_submitValues['_qf_MessageTemplates_upload'])) {