- Issue created by @JennyDumitrescu
- 🇨🇭Switzerland berdir Switzerland
Hi @JennyDumitrescu
After a first look, what I can tell you is that the mapping currently only works for entity reference fields to Taxonomy terms, this seems to work fairly well, it auto-creates the terms for either radios and checkboxes and assigns them correctly.
Would that work for you? If not, can you share the content structure you'd like to use, I'd assume it would be a list_text field?
Note: I did find a Drupal 10 compatibility issue when testing this and I'll fix that in 🐛 D10: Missing accessCheck() call on entity query in MappingEditFormBase::automaticTermsGenerator Fixed
- Status changed to Needs review
almost 2 years ago 3:26pm 31 May 2023 - last update
almost 2 years ago 5 pass - 🇨🇭Switzerland berdir Switzerland
Here is a first patch that allows to map radios and checkboxes to list_string fields.
Notes:
* There is no cardinality check yet. You can currently map a checkboxes field to a single-value list_string field in Drupal, but it will then only save the first value
* Note that it will automatically and unconditionally replace the allowed values options with the IDs and labels of the radios and checkboxes in the GatherContent template. This will be a problem if you have existing content.
* The Other.. option of a Radios field in a GatherContent template is not supported, there was some preliminary support for that in code with a string field and a custom widget, but it's not complete and not working, so not available as an option for now. - 🇬🇧United Kingdom JennyDumitrescu
Hey @berdir,
I can confirm the mapping to taxonomy works in a D9 site as expected. I think the only time this type of mapping isn't suitable was for a simple boolean type field yes/no. The above patch for the mapping to a list_string field should work for that and prevent us needing taxonomy terms for more simple options. If this was progressed to working to save multiple options as it does for taxonomy terms that would be great.
I'll test this out on our site today if I get a chance and report back. I think it was a mis-match from the information on GatherContent's help article which stated they had to match to a variety of the simple text fields.
- 🇨🇭Switzerland berdir Switzerland
Thanks for the feedback.
Yes, agree that there are useful scenarios where list field is enough, a yes/no with a single checkbox could even be mapped to a boolean field, but that would be a bit more work and not sure what would need to happen if there's ever a third option in the GatherContent template.
- Status changed to Fixed
over 1 year ago 10:01am 14 November 2023 Automatically closed - issue fixed for 2 weeks with no activity.