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 default 'is searchable' to prevent breaking advanced search #18970

Merged
merged 1 commit into from
Nov 15, 2020

Conversation

MegaphoneJon
Copy link
Contributor

https://lab.civicrm.org/dev/core/-/issues/2188

Overview

Searchable custom fields of type "Integer" with radio buttons can cause Advanced Search to break.

Before

a JS error in Advanced Search that breaks other JS, e.g.:

Uncaught query function not defined for Select2 custom_9_from

After

Advanced Search works correctly.

Technical Details

The "Add Custom Field" form has a default for "Search by Range" set to "Yes", which is hidden by JS until someone sets "Is Searchable" to "Yes".

However, there's no widget to search by range on a multiple-choice field (it doesn't really make sense) so "Search by Range" remains hidden. Unfortunately, that means the field takes the default of "Yes". Advanced Search breaks because the widget doesn't exist.

The solution IMO is to change the default for the "Search by Range" field. I think the argument in defaulting to "Yes" is weak in general.

Comments

This issue exists in master, but has existed at least as far back as 5.13.

No test because it's 100% form level. This doesn't happen when adding fields via API.

@civibot
Copy link

civibot bot commented Nov 13, 2020

(Standard links)

@civibot civibot bot added the master label Nov 13, 2020
@colemanw
Copy link
Member

I think this is a sensible change but doesn't solve the problem for existing fields. Perhaps an upgrade script?

@colemanw colemanw merged commit e1abc8e into civicrm:master Nov 15, 2020
@agileware-justin
Copy link
Contributor

@MegaphoneJon thanks for the fix, works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants