Skip to content

Commit

Permalink
Display ContributionPage custom fields
Browse files Browse the repository at this point in the history
  • Loading branch information
aydun committed Nov 15, 2024
1 parent 60a050d commit d46d25c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion CRM/Contribute/Form/ContributionPage/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ContributionPage {
use CRM_Custom_Form_CustomDataTrait;

/**
* Set variables up before form is built.
*/
public function preProcess() {
parent::preProcess();
$this->setSelectedChild('settings');

// Must set entityID for defaults to load via AJAX.
$this->assign('entityID', $this->_id);

if ($this->isSubmitted()) {
// The custom data fields are added to the form by an ajax form.
// However, if they are not present in the element index they will
// not be available from `$this->getSubmittedValue()` in post process.
// We do not have to set defaults or otherwise render - just add to the element index.
$this->addCustomDataFieldsToForm('ContributionPage');
}
}

/**
Expand Down Expand Up @@ -297,7 +309,7 @@ public static function formRule($values, $files, $self) {
*/
public function postProcess() {
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
$params = $this->getSubmittedValues();

// we do this in case the user has hit the forward/back button
if ($this->_id) {
Expand All @@ -321,6 +333,8 @@ public function postProcess() {
$params['honor_block_text'] = NULL;
}

$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_id, 'ContributionPage');

$dao = CRM_Contribute_BAO_ContributionPage::writeRecord($params);

$ufJoinParams = [
Expand Down
2 changes: 2 additions & 0 deletions templates/CRM/Contribute/Form/ContributionPage/Settings.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
</tr>
{/if}
</table>
{include file="CRM/common/customDataBlock.tpl" customDataType='ContributionPage'}

<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
</div>

Expand Down

0 comments on commit d46d25c

Please sign in to comment.