From 0e700ee7b7386729f66de84c833249102110eaf3 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 29 Oct 2018 13:29:09 +1300 Subject: [PATCH] Fix Contribution settings form per dev/core/473 --- CRM/Admin/Form/Preferences/Contribute.php | 28 ++++------------------- CRM/Admin/Form/SettingTrait.php | 3 ++- settings/Contribute.setting.php | 12 +++++----- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php index f650ec51de..8e51270b0d 100644 --- a/CRM/Admin/Form/Preferences/Contribute.php +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -126,16 +126,17 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { public function buildQuickForm() { $htmlFields = array(); foreach ($this->_settings as $setting => $group) { + // @todo - remove this whole loop! The parent form does this - it's just because of the werid handling + // of $htmlFields for this form that needs to be unwound that we have it atm. + // The 'basicform' has been contaminated with processing $htlFields + // to cater to this form - probably due to the way invoicing settings were handled as + // an array not a bunch of keys. $settingMetaData = civicrm_api3('setting', 'getfields', array('name' => $setting)); $props = $settingMetaData['values'][$setting]; if (isset($props['quick_form_type'])) { $add = 'add' . $props['quick_form_type']; if ($add == 'addElement') { if (in_array($props['html_type'], array('checkbox', 'textarea'))) { - $this->add($props['html_type'], - $setting, - $props['title'] - ); } else { if ($props['html_type'] == 'select') { @@ -144,24 +145,8 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { $props['option_values'] = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::$functionName(); } } - $this->$add( - $props['html_type'], - $setting, - ts($props['title']), - CRM_Utils_Array::value($props['html_type'] == 'select' ? 'option_values' : 'html_attributes', $props, array()), - $props['html_type'] == 'select' ? CRM_Utils_Array::value('html_attributes', $props) : NULL - ); } } - elseif ($add == 'addMonthDay') { - $this->add('date', $setting, ts($props['title']), CRM_Core_SelectValues::date(NULL, 'M d')); - } - elseif ($add == 'addDate') { - $this->addDate($setting, ts($props['title']), FALSE, array('formatType' => $props['type'])); - } - else { - $this->$add($setting, ts($props['title'])); - } } $htmlFields[$setting] = ts($props['description']); } @@ -197,9 +182,6 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { unset($params['qfKey']); unset($params['entryURL']); Civi::settings()->set('contribution_invoice_settings', $params); - Civi::settings()->set('update_contribution_on_membership_type_change', - CRM_Utils_Array::value('update_contribution_on_membership_type_change', $params) - ); // to set default value for 'Invoices / Credit Notes' checkbox on display preferences $values = CRM_Core_BAO_Setting::getItem("CiviCRM Preferences"); diff --git a/CRM/Admin/Form/SettingTrait.php b/CRM/Admin/Form/SettingTrait.php index 827b44c56c..424facdc41 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -202,7 +202,8 @@ trait CRM_Admin_Form_SettingTrait { * @return string */ protected function getQuickFormType($spec) { - if (isset($spec['quick_form_type'])) { + if (isset($spec['quick_form_type']) && + !($spec['quick_form_type'] === 'Element' && !empty($spec['html_type']))) { return $spec['quick_form_type']; } $mapping = [ diff --git a/settings/Contribute.setting.php b/settings/Contribute.setting.php index 5bceb7424e..41b9cc8e12 100644 --- a/settings/Contribute.setting.php +++ b/settings/Contribute.setting.php @@ -73,7 +73,7 @@ return array( 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'invoicing', - 'type' => 'Integer', + 'type' => 'Boolean', 'html_type' => 'checkbox', 'quick_form_type' => 'Element', 'default' => 0, @@ -88,7 +88,7 @@ return array( 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'acl_financial_type', - 'type' => 'Integer', + 'type' => 'Boolean', 'html_type' => 'checkbox', 'quick_form_type' => 'Element', 'default' => 0, @@ -103,7 +103,7 @@ return array( 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'deferred_revenue_enabled', - 'type' => 'Integer', + 'type' => 'Boolean', 'html_type' => 'checkbox', 'quick_form_type' => 'Element', 'default' => 0, @@ -119,7 +119,7 @@ return array( 'group' => 'contribute', 'name' => 'default_invoice_page', 'type' => 'Integer', - 'quick_form_type' => 'Element', + 'quick_form_type' => 'Select', 'default' => NULL, 'pseudoconstant' => array( // @todo - handle table style pseudoconstants for settings & avoid deprecated function. @@ -137,7 +137,7 @@ return array( 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'always_post_to_accounts_receivable', - 'type' => 'Integer', + 'type' => 'Boolean', 'html_type' => 'checkbox', 'quick_form_type' => 'Element', 'default' => 0, @@ -152,7 +152,7 @@ return array( 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'update_contribution_on_membership_type_change', - 'type' => 'Integer', + 'type' => 'Boolean', 'html_type' => 'checkbox', 'quick_form_type' => 'Element', 'default' => 0, -- 2.25.1