Skip to content

Commit

Permalink
Merge pull request #617 from seamuslee001/7.x-5.28
Browse files Browse the repository at this point in the history
5.28 Fixed for multi-select filter
  • Loading branch information
seamuslee001 authored Aug 21, 2020
2 parents 295e9ab + 28b7187 commit 08afc15
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions modules/views/civicrm.views.inc
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ function civicrm_views_custom_data_cache(&$data, $entity_type, $group_id, $sub_t
'help' => empty($current_field['help_post']) ? t('Custom Data Field') : $current_field['help_post'],
'field' => civicrm_views_get_field($current_field['data_type'], $current_field['html_type']),
'argument' => civicrm_views_get_argument($current_field['data_type']),
'filter' => civicrm_views_get_filter($current_field['data_type'], $current_field['html_type'], $option_group_id),
'filter' => civicrm_views_get_filter($current_field['data_type'], $current_field['html_type'], $option_group_id, ($current_field['serialize'] ?? 0)),
'sort' => civicrm_views_get_sort($current_field['data_type']),
'relationship' => civicrm_views_get_relationship($current_field['data_type']),
);
Expand Down Expand Up @@ -565,32 +565,30 @@ function civicrm_views_get_argument($type) {
/**
* Acquire the proper filter handler by checking against the field's data_type as defined by CRM_Utils_Type.
*
* @param $data_type
* A String containing the field data type
* @param $html_type
* A string containing the field html type
* @param string $data_type
* Field data type
* @param string $html_type
* Field html type
* @param int $option_group_id
* Option Group id incase of option list field.
* @param bool $isMultiSelect
* Multi-select field?
*
* @return array
* An array containing the handler name and any extra settings
*/
function civicrm_views_get_filter($data_type, $html_type = NULL, $option_group_id = NULL) {
// Relying on html types as opposed to data types seems like a code smell.
// Would love to be able to remove this logic.
$customMultiValueHTMLTypes = array(
'Multi-Select', 'CheckBox', 'Multi-Select Country',
'Multi-Select State/Province',
);
if ($html_type == 'Multi-Select Country') {
function civicrm_views_get_filter($data_type, $html_type = NULL, $option_group_id = NULL, $isMultiSelect = 0) {
if ($html_type == 'Country' && $isMultiSelect) {
return array(
'handler' => 'civicrm_handler_filter_country_multi',
);
}
elseif ($html_type == 'Multi-Select State/Province') {
elseif ($html_type == 'State/Province' && $isMultiSelect) {
return array(
'handler' => 'civicrm_handler_filter_state_multi',
);
}
elseif (!empty($option_group_id) && in_array($html_type, $customMultiValueHTMLTypes)) {
elseif (!empty($option_group_id) && $isMultiSelect) {
return array(
'handler' => 'civicrm_handler_filter_custom_option',
);
Expand Down

0 comments on commit 08afc15

Please sign in to comment.