Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Contribution settings form per dev/core/473 #13022

Merged
merged 1 commit into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions CRM/Admin/Form/Preferences/Contribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,17 @@ public function preProcess() {
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') {
Expand All @@ -144,24 +145,8 @@ public function buildQuickForm() {
$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']);
}
Expand Down Expand Up @@ -197,9 +182,6 @@ public function postProcess() {
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");
Expand Down
3 changes: 2 additions & 1 deletion CRM/Admin/Form/SettingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ protected function addFieldsDefinedInSettingsMetadata() {
* @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 = [
Expand Down
12 changes: 6 additions & 6 deletions settings/Contribute.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'invoicing',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'quick_form_type' => 'Element',
'default' => 0,
Expand All @@ -88,7 +88,7 @@
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'acl_financial_type',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'quick_form_type' => 'Element',
'default' => 0,
Expand All @@ -103,7 +103,7 @@
'group_name' => 'Contribute Preferences',
'group' => 'contribute',
'name' => 'deferred_revenue_enabled',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'quick_form_type' => 'Element',
'default' => 0,
Expand All @@ -119,7 +119,7 @@
'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.
Expand All @@ -137,7 +137,7 @@
'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,
Expand All @@ -152,7 +152,7 @@
'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,
Expand Down