Skip to content

Commit

Permalink
Fix handling of advmutltiselect (on localization form) Add deprecatio…
Browse files Browse the repository at this point in the history
…n notice rather than hard-fail for incorrect case for html type.

We have clarified the correct syntax (it was haphazard) an updated the docs.

This ALSO fixes fails on localisation form
  • Loading branch information
eileenmcnaughton committed Nov 5, 2018
1 parent a33f28e commit 5c33bd6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CRM/Admin/Form/SettingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,17 @@ protected function addFieldsDefinedInSettingsMetadata() {
protected function getQuickFormType($spec) {
if (isset($spec['quick_form_type']) &&
!($spec['quick_form_type'] === 'Element' && !empty($spec['html_type']))) {
// This is kinda transitional
return $spec['quick_form_type'];
}

// The spec for settings has been updated for consistency - we provide deprecation notices for sites that have
// not made this change.
$htmlType = $spec['html_type'];
if ($htmlType !== strtolower($htmlType)) {
CRM_Core_Error::deprecatedFunctionWarning(ts('Settings fields html_type should be lower case - see https://docs.civicrm.org/dev/en/latest/framework/setting/ - this needs to be fixed for ' . $spec['name']));
$htmlType = strtolower($spec['html_type']);
}
$mapping = [
'checkboxes' => 'CheckBoxes',
'checkbox' => 'CheckBox',
Expand All @@ -229,8 +238,9 @@ protected function getQuickFormType($spec) {
'textarea' => 'Element',
'text' => 'Element',
'entity_reference' => 'EntityRef',
'advmultiselect' => 'Element',
];
return $mapping[$spec['html_type']];
return $mapping[$htmlType];
}
/**
* Get the defaults for all fields defined in the metadata.
Expand Down

0 comments on commit 5c33bd6

Please sign in to comment.