-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
CustomField - Support filters in EntityReference fields #25960
Conversation
(Standard links)
|
5b8b607
to
c39aded
Compare
@@ -46,7 +46,8 @@ public function __construct($name = NULL, array $data = [], $dataName = '') { | |||
} | |||
|
|||
public function setUpHeadless(): CiviEnvBuilder { | |||
return Test::headless()->apply(); | |||
// TODO: search_kit should probably be part of the 'headless()' baseline. | |||
return Test::headless()->install(['org.civicrm.search_kit'])->apply(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this move seems like a good balance.
Coleman linked this in another discussion, where it had been left as an open-question about how far up to move the install(...search_kit...)
statement. The tension in that question: Search Kit is a "required extension", but that concept is contradictory:
- As a "required" thing, it should be enabled by default in all integration tests (to make them more representative of the real runtime - and to avoid redundant boilerplate).
- As an "extension", it should be a discrete thing with clear boundaries (and you can't enforce/test those boundaries if it's always-on).
That's a tricky line. The current patch is a decent balance (enabling it for a large block of tests where they're likely to be needed -- without making it totally required or affecting 3rd party suites).
This ensures filters are applied on both quickforms and afforms when defined for a custom field. Note: There is still no UI for adding these filters to a custom field, but they can be set via api explorer.
c39aded
to
85cc9cc
Compare
We're currently testing this, I'll add a review soon. |
Hi there.
This prevents users from confusing the functionalities associated with certain event types. I was able to define the filters in two different corresponding ways, both of which make sense from my point of view:
|
Thanks for the review @TychoSchottelius - sounds like this is merge-ready. Did you have anything to add @jensschuppe or is this good to merge? |
@colemanw I think I agree 😄 Thanks, this makes Entity Reference Custom Fields much more useful! |
... maybe this should be documented somewhere in the docs, alongside the fact that those global per-field filters will always apply, even when an Afform defines additional filtering via SearchKit. |
Thanks very much @colemanw, this adds a lot more flexiblity and power to CiviCRM. |
Overview
This adds basic support for filters on the new custom field type EntityReference.
Before
Filters supported on the old ContactReference custom field type, but not for the new EntityReference.
After
Filters now work for EntityReference forms. Minimalist "Advanced Filter" textfield now shown for EntityReference as well as ContactReference fields:
Technical Details
As of e9fe23e APIv4 started passing anything stored in the
CustomField.filter
column to thegetFields
metadata. This completes that work by ensuring the filters are applied at runtime for all forms (both Quickform and Afform), and exposing the filters to the create/edit custom field form.Comments
This is not a great UX but it's a start. SearchKit-style field selectors would be an improvement but would require mixing Angular code into the create/edit custom field form which is QuickForm-based. Adding Angular code to that form would be a little tricky but not impossible.