From: Eileen McNaughton Date: Tue, 19 Sep 2023 10:23:45 +0000 (+1200) Subject: Php8.x Fix notices when creating custom field X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7dfc78b11c461ea64044e030bd3c03c0dc9d3af9;p=civicrm-core.git Php8.x Fix notices when creating custom field --- diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index a61292f666..9a8c2e3d73 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -238,7 +238,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { 'select' => ['minimumInputLength' => 0], ]); - if ($this->_action == CRM_Core_Action::UPDATE) { + $isUpdateAction = $this->_action == CRM_Core_Action::UPDATE; + if ($isUpdateAction) { $this->freeze('data_type'); if (!empty($this->_values['option_group_id'])) { $this->assign('hasOptionGroup', in_array($this->_values['html_type'], self::$htmlTypesWithOptions)); @@ -247,12 +248,10 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $optionGroupParams['id'] = $this->_values['option_group_id']; $optionGroupParams['options']['or'] = [["is_reserved", "id"]]; } - $this->assign('originalHtmlType', $this->_values['html_type']); - $this->assign('originalSerialize', $this->_values['serialize']); - if (!empty($this->_values['serialize'])) { - $this->assign('existingMultiValueCount', $this->getMultiValueCount()); - } } + $this->assign('existingMultiValueCount', ($isUpdateAction && !empty($this->_values['serialize'])) ? $this->getMultiValueCount() : NULL); + $this->assign('originalSerialize', $isUpdateAction ? $this->_values['serialize'] : NULL); + $this->assign('originalHtmlType', $isUpdateAction ? $this->_values['html_type'] : NULL); // Retrieve optiongroups for selection list $optionGroupMetadata = civicrm_api3('OptionGroup', 'get', $optionGroupParams); diff --git a/templates/CRM/Custom/Form/Field.tpl b/templates/CRM/Custom/Form/Field.tpl index 68733a0d08..2cfe7802b6 100644 --- a/templates/CRM/Custom/Form/Field.tpl +++ b/templates/CRM/Custom/Form/Field.tpl @@ -33,7 +33,7 @@ {$form.serialize.label} {$form.serialize.html} - {if !empty($form.in_selector)} + {if array_key_exists('in_selector', $form)} {$form.in_selector.label} {$form.in_selector.html} {help id="id-in_selector"}