From 4a287654b7c91a44f1ab92acd7389d5da199e3ec Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 23 Sep 2023 10:48:59 +1200 Subject: [PATCH] Update Renderer::_tplFetch to work with Smarty3 --- CRM/Core/Form/Renderer.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CRM/Core/Form/Renderer.php b/CRM/Core/Form/Renderer.php index 92e23e7a50..11f40d86ed 100644 --- a/CRM/Core/Form/Renderer.php +++ b/CRM/Core/Form/Renderer.php @@ -217,6 +217,34 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty { $element->updateAttributes($attributes); } + /** + * Process an template sourced in a string with Smarty + * + * This overrides the quick form function which has not been updated in a while. + * + * The function is called when render the code to mark a field as 'required' + * + * The notes on the quick form function seem to refer to older smarty - ie: + * Smarty has no core function to render a template given as a string. + * So we use the smarty eval plugin function to do this. + * + * @param string $tplSource The template source + */ + public function _tplFetch($tplSource) { + // Smarty3 does not have this function defined so the parent fails. + // Adding this is preparatory to smarty 3.... + if (!function_exists('smarty_function_eval') && !file_exists(SMARTY_DIR . '/plugins/function.eval.php')) { + $smarty = $this->_tpl; + $smarty->assign('var', $tplSource); + return $smarty->fetch("string:$tplSource"); + } + // This part is what the parent does & is suitable to Smarty 2. + if (!function_exists('smarty_function_eval')) { + require SMARTY_DIR . '/plugins/function.eval.php'; + } + return smarty_function_eval(['var' => $tplSource], $this->_tpl); + } + /** * Convert IDs to values and format for display. * -- 2.25.1