From 16d010becf4b0eeb427ec929a20cd783e7772537 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 30 Sep 2011 14:59:41 +0000 Subject: [PATCH] If hooked, keep app in extension_data to persist across etemplate loops. Fixes lost infolog custom fields in addressbook view when changing nm filters --- etemplate/inc/class.customfields_widget.inc.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.customfields_widget.inc.php b/etemplate/inc/class.customfields_widget.inc.php index dad6cf9ff9..9d79d93de1 100644 --- a/etemplate/inc/class.customfields_widget.inc.php +++ b/etemplate/inc/class.customfields_widget.inc.php @@ -26,6 +26,7 @@ class customfields_widget { var $public_functions = array( 'pre_process' => True, + 'post_process' => True, ); var $human_name = array( 'customfields' => 'custom fields', @@ -112,10 +113,16 @@ class customfields_widget function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,etemplate $tmpl) { list($app) = explode('.',$tmpl->name); + if($extension_data['app']) $app = $extension_data['app']; // if we are in the etemplate editor or the app has no cf's, load the cf's from the app the tpl belongs too - if ($app && $app != 'stylite' && $app != $this->appname && ($this->appname == 'etemplate' || !$this->customfields || etemplate::$hooked)) + if ($app && $app != 'stylite' && $app != $this->appname && ( + $this->appname == 'etemplate' || !$this->customfields || etemplate::$hooked || $extension_data['app'] + )) { self::__construct(null,$app); // app changed + + // Need to keep hooked app for things like nm filter changes and validation errors + if(etemplate::$hooked) $extension_data['app'] = $app; } list($type2,$use_private,$field_names) = explode(',',$cell['size'],3); $fields_with_vals=array(); @@ -493,6 +500,12 @@ class customfields_widget return True; // extra Label is ok } + /** + * Override to pass along extension_data - doesn't happen otherwise + */ + public function post_process($name,&$value,&$extension_data,&$loop,etemplate &$tmpl,$value_in) { + } + /** * Read the options of a 'select' or 'radio' custom field from a file *