-
-
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
core#2386 - metadata-driven chain-select fields #19629
Conversation
(Standard links)
|
Thanks for this @MegaphoneJon I'm trying to understand how to test it. When I visit |
@colemanw That makes a lot of sense, I'll do that. |
@colemanw I replaced I encountered this first in an extension where the name of my country/state fields don't line up this way - and I could just change the names, but it seems like there's a deeper need for chain-select that's decoupled from the existing country/state and state/county workflows. I'm OK with letting the scope creep here if we can achieve consensus on how to implement this. A closely related issue is the ability to add an |
Ah - the reason it works is also because |
I think @eileenmcnaughton would know the answer to that. |
@MegaphoneJon I think the comment is a deprecation of sorts but could be more explicit |
@eileenmcnaughton I'll open a PR to move it into the "deprecated properties" section below then. To recap here - there's no implementation of We should have a sense of how we'll implement afform chain-select to ensure this doesn't lock in a bad contract. |
I tested this and it works. I will put up an another PR that facilitates swapping out this field to use it without doing all the fields on the form |
Afform does have a chain-select implementation already. You can see it in action by creating a simple Contact + Address form. It works via metadata. |
This builds on civicrm#19629 Our intention is that we should be building functionality into this form that is actually used in core. It's a bit tricky to swap out all fields at once but this makes them individually swap-outable. Only defaultContactCountry is swapped out. I looked a little at the help_text issue - the text actually does work if you add it since it's already in the hlp file but I decided this broke consistency less (using description) as other fields on the form do that and look similar. Also, when the text is really just a bit of text (not a long help text) it makes sense. (Otherwise I'd need to trawl through resolving the bigger issue and I didn't want to bring that into scope)
This builds on civicrm#19629 Our intention is that we should be building functionality into this form that is actually used in core. It's a bit tricky to swap out all fields at once but this makes them individually swap-outable. Only defaultContactCountry is swapped out. I looked a little at the help_text issue - the text actually does work if you add it since it's already in the hlp file but I decided this broke consistency less (using description) as other fields on the form do that and look similar. Also, when the text is really just a bit of text (not a long help text) it makes sense. (Otherwise I'd need to trawl through resolving the bigger issue and I didn't want to bring that into scope)
#19697 convertst the field @colemanw the metadata for the settings is a bit different - 'something' has to know the relation between country & state fields. Note that the metadata @MegaphoneJon added has done that |
Actually it's the same in Afform. You might want to verify that @MegaphoneJon's approach is consistent to Afform's, which is to use the APIv4 "county_id": {
"label": "County",
"input_type": "ChainSelect",
"input_attrs": {
"label": "County",
"controlField": "state_province_id"
}
},
"state_province_id": {
"label": "State/Province",
"input_type": "ChainSelect",
"input_attrs": {
"label": "State/Province",
"controlField": "country_id"
}
},
"country_id": {
"label": "Country",
"input_type": "Select",
"input_attrs": {
"label": "Country"
}
}, |
@MegaphoneJon ok it seems we need the to align with 'input_attrs' (because we love words like 'attrs' that presumably mean 'attributes' in a random sorta way) |
Also APIv4 uses camelCase for |
@colemanw I think we still can if we want to |
@eileenmcnaughton I thought from this that I would need to rework this PR, but I see it's merged. Was that in error? |
@MegaphoneJon yep - @colemanw helpfully pointed it out after I merged it |
@MegaphoneJon you might pull in #19697 when youwork on it to check it works against that |
https://lab.civicrm.org/dev/core/-/issues/2386
Overview
As we move to metadata-based settings, we need to support existing use cases such as chain-select.
Before
It looks like someone started writing code to allow defining chain-selects in
*.setting.php
but didn't finish.After
Chain-selects work., we can create metadata-driven chain-select fields.
Technical Details
This adds a new property for settings,
chain_select_properties
. These values are passed toCRM_Core_Form::addChainSelect
.Comments
I'm not sure how tightly the properties of
CRM_Core_Form::addChainSelect
are coupled to Quickform. If they are, we may need a more generic solution - like a settings property that defines a JS function to run on anonclick
event.If this PR is accepted, I will add documentation in the Settings Reference.