From: Eileen McNaughton Date: Sun, 17 Dec 2023 20:45:11 +0000 (+1300) Subject: Set formBuilt to TRUE when, erm, it is built X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b1243e659435fcc48d8de76290f62321fc7677d7;p=civicrm-core.git Set formBuilt to TRUE when, erm, it is built --- diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index abccf9acd3..6f7f033eb7 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -2401,10 +2401,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP */ public function getPriceSetID(): ?int { $priceSetID = $this->getSubmittedValue('price_set_id') ?: CRM_Utils_Request::retrieve('priceSetId', 'Integer'); - // Ideally we would use $this->isFormBuilt() here to know when to access the _POST - // array directly. However, the parent sets isBuilt before, building the form, - // rather than after. - if (!$priceSetID && !empty($this->getSubmitValue('price_set_id'))) { + if (!$this->isFormBuilt() && !empty($this->getSubmitValue('price_set_id'))) { return (int) $this->getSubmitValue('price_set_id'); } return $priceSetID ?? NULL; diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index f31e0ac0fb..6cab90d985 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -726,10 +726,6 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * buildQuickForm. */ public function buildForm() { - // @todo - move this to the end of the function - then it can be checked - // ie $this->isBuilt() to determine whether variables are not yet in getSubmittedValues() - $this->_formBuilt = TRUE; - $this->preProcess(); CRM_Utils_Hook::preProcess(get_class($this), $this); @@ -787,6 +783,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { // it's already been initialized. self::$_template->ensureVariablesAreAssigned($this->expectedSmartyVariables); self::$_template->addExpectedTabHeaderKeys(); + $this->_formBuilt = TRUE; } /**