-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
CustomFields - Improve metadata about which custom groups belong to which entities #23336
Conversation
(Standard links)
|
2c6b254
to
b40d860
Compare
b40d860
to
54dbcc1
Compare
54dbcc1
to
4fe046b
Compare
5263a86
to
2acbf1b
Compare
See civicrm/civicrm-core#23336 which makes the callable function in 'description' obsolete.
781dd13
to
d6f6dec
Compare
PR review note: in addition to new tests added in this PR, this functionality is massively covered by existing tests, notably the APIv3 syntaxConformanceTest which checks every entity for custom fields. Lots of other APIv4 and APIv3 tests cover custom data as well. |
04bd6ad
to
20c8b8d
Compare
… types Fixes dev/core#2905 Before: Hard coded, plus a very strange use of the 'description' field to store a callback function. After: The 'grouping' field in the OptionValue for custom extends and custom type is used. APIv4 getfields can then retrieve the necessary options.
This allows the API to filter custom groups by entity type and other values.
20c8b8d
to
dab64f2
Compare
I gave this an r-run by creating custom fields for some of the more obscure types - grant, survey, participant-event and was able to create the fields & edit and save the values. I'm OK with merging this but I just want to be sure that some thought has gone into the cleanup on the Grant mgd option value - since we seem to have had no-end of issues around grant mgd option values - I guess unlike the others this one is all new? |
@colemanw I'm going to merge this since I don't think my question above is blocking & I know you have targetted the upgrade scripts at 5.49 - if necessary we can fix as a follow up. @demeritcowboy might have thoughts on it too |
Thanks @eileenmcnaughton. I believe we've got all the kinks worked out for those managed entities at this point. Should be smooth on upgrades and new installs alike, as in both cases this will be inserting a new option value. |
Overview
This makes the relationship between Custom Field Groups, entity types and subtypes discoverable via APIv4 metadata. This paves the way for Afform and SearchKit to handle custom fields intelligently, and for extensions to easily provide new types of entities with complex custom data mapping.
Before
Metadata did not exist. Custom field groups to load for each entity type was hard-coded on forms and templates throughout CiviCRM. Generic handling was not possible.
After
Metadata-driven tools like Afform and SearchKit will be able to gather custom fields for entity types and sub-types via the API.
Virtual entities with sub-types (like ECK) can easily extend the mapping.
Unit tests added.
Technical Details
In addition to adding metadata, this PR resolves a few oddities:
Grant
entities was still hard-coded in core even though CiviGrant has been moved to an extension. I switched it to use thecg_extend_objects
optionGroup and removed the Grant hard-coding from core.CustomGroup.extends
column or if they were only for presentation on the custom group quickform. I investigated and it turns out to be the latter. APIv3 CustomGroup.create has some special logic to transform e.g.extends: 'ParticipantEventName'
intoextends: 'Participant'
with the appropriate value forextends_entity_column_id
. I kept that around but removed unreachable code for handling those pseudo-values being stored in theextends
column.OptionValue.description
column by CiviCase, where it was actually storing the name of a callable function to return the list of case types. That's problematic for several reasons, not the least of which is thatdescription
is a localized field so the whole thing would break in multilingual mode! I switched over to a "grouping" value ofcase_type_id
and taught the code to just call getFields on that field name.