Unable to map checkbox/radio fields

Created on 16 May 2023, almost 2 years ago
Updated 14 November 2023, over 1 year ago

Problem/Motivation

We're unable to map in a checkbox or radio field from Gather Content into our Drupal site. Using 9.5.9 and a variety of text fields (tried Text (formatted, long), Text (formatted), List (text), Text (plain), Text (plain, long) as well as taxonomy term reference) and none appear in the mapping option for the checkbox or radio fields. See images attached for mapping selection and Gather Content settings. All fields tried do show as mapping options for other text fields though but not as per the instructions at https://help.gathercontent.com/en/articles/369653-drupal-integration-ste... where we've used the fields described for D8.

🐛 Bug report
Status

Fixed

Version

6.0

Component

Code

Created by

🇬🇧United Kingdom JennyDumitrescu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • 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
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    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.

  • 🇨🇭Switzerland berdir Switzerland

    Committed.

    • Berdir committed 8364b04e on 6.x
      Issue #3360740 by Berdir: Unable to map checkbox/radio fields
      
  • Status changed to Fixed over 1 year ago
  • 🇨🇭Switzerland berdir Switzerland
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024