Radios or Checkboxes inside Composite not saved

Created on 2 June 2021, about 3 years ago
Updated 21 November 2023, 7 months ago
example_field:
    '#type': custom_composite
    '#title': 'Label'
    '#multiple__header': false
    '#multiple__item_label': 'Tankkaart'
    '#multiple__min_items': 1
    '#multiple__empty_items': 0
    '#multiple__sorting': false
    '#multiple__add': false
    '#multiple__remove': false
    '#multiple__add_more_input': false
    '#multiple__add_more_button_label': 'Voeg nog een itemtoe'
    '#wrapper_type': container
    '#element':
      products:
        '#type': checkboxes
        '#options':
          diesel+adblue: 'Diesel en AdBlue'
          benzine+95+e10: 'Benzine 95 E10'
          benzine+98+e5: 'Benzine 98 E5'
          lpg: LPG
          gasolie+diesel: 'Gasolie diesel (rode mazout)'
          kero+type+c: 'Kero Type C'
        '#title': Producten

submission in database is "Array" and also in the mail is "Array"

Feature request
Status

Needs review

Version

6.2

Component

Code

Created by

🇧🇪Belgium michiellucas

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada bbombachini London, ON

    I'm on D9.5 and php 8.1

    Tried the patch #48 with webforms 6.1.4 and tried the patch from the MR (https://git.drupalcode.org/project/webform/-/merge_requests/123.patch) with version 6.2.0-beta5 (latest release) and the dev version but all the 3 gave me the same error as #50:

    TypeError: Illegal offset type in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 136 of /var/www/sdgs.localhost/web/core/lib/Drupal/Core/Render/Element/Checkboxes.php)

    So I'm moving this to needs work.

  • 🇫🇮Finland phonkala

    For me the parth #48 works fine right after applying it, using Drupal 10.0.8, Webforms 6.2.0-beta5 and PHP 8.1. This feature was very much needed and as it's just saving the data as JSON string, I don't think adding this to the actual module would be much of an issue. However if that is not desired, maybe this could be moved to a separate module while it's not considered stable?

    And for @bbombachini, I had no issue using checkboxes and submitting form, no errors there.

  • 🇨🇦Canada bbombachini London, ON

    Interesting @phonkala, I'm still testing this on D9.5.3, webform 6.2.0-beta5, PHP 8.1, and the patch from #48. And I still have the same error:

    TypeError: Illegal offset type in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 136 of core/lib/Drupal/Core/Render/Element/Checkboxes.php).

    So I created a simple webform for testing, can you try using this form and tell me what it gives you for $element[$key] on line 36 of core/lib/Drupal/Core/Render/Element/Checkboxes.php?

    uuid: 04b7199e-cd72-46ba-954d-d4e196f58f43
    langcode: en
    status: open
    dependencies: {  }
    weight: 0
    open: null
    close: null
    uid: 85
    template: false
    archive: false
    id: test
    title: Test
    description: ''
    category: ''
    elements: |-
      custom_composite_test:
        '#type': webform_custom_composite
        '#title': 'Custom composite test'
        '#element':
          select_options:
            '#type': webform_checkboxes_other
            '#options':
              test1: 'Test 1'
              test2: 'Test 2'
              test3: 'Test 3'
              test4: 'Test 4'
            '#title': 'Select options'
    css: ''
    javascript: ''
    settings:
      ajax: false
      ajax_scroll_top: form
      ajax_progress_type: ''
      ajax_effect: ''
      ajax_speed: null
      page: true
      page_submit_path: ''
      page_confirm_path: ''
      page_theme_name: ''
      form_title: both
      form_submit_once: false
      form_open_message: ''
      form_close_message: ''
      form_exception_message: ''
      form_previous_submissions: true
      form_confidential: false
      form_confidential_message: ''
      form_disable_remote_addr: false
      form_convert_anonymous: false
      form_prepopulate: false
      form_prepopulate_source_entity: false
      form_prepopulate_source_entity_required: false
      form_prepopulate_source_entity_type: ''
      form_unsaved: false
      form_disable_back: false
      form_submit_back: false
      form_disable_autocomplete: false
      form_novalidate: false
      form_disable_inline_errors: false
      form_required: false
      form_autofocus: false
      form_details_toggle: false
      form_reset: false
      form_access_denied: default
      form_access_denied_title: ''
      form_access_denied_message: ''
      form_access_denied_attributes: {  }
      form_file_limit: ''
      form_attributes: {  }
      form_method: ''
      form_action: ''
      share: false
      share_node: false
      share_theme_name: ''
      share_title: true
      share_page_body_attributes: {  }
      submission_label: ''
      submission_exception_message: ''
      submission_locked_message: ''
      submission_log: false
      submission_excluded_elements: {  }
      submission_exclude_empty: false
      submission_exclude_empty_checkbox: false
      submission_views: {  }
      submission_views_replace: {  }
      submission_user_columns: {  }
      submission_user_duplicate: false
      submission_access_denied: default
      submission_access_denied_title: ''
      submission_access_denied_message: ''
      submission_access_denied_attributes: {  }
      previous_submission_message: ''
      previous_submissions_message: ''
      autofill: false
      autofill_message: ''
      autofill_excluded_elements: {  }
      wizard_progress_bar: true
      wizard_progress_pages: false
      wizard_progress_percentage: false
      wizard_progress_link: false
      wizard_progress_states: false
      wizard_start_label: ''
      wizard_preview_link: false
      wizard_confirmation: true
      wizard_confirmation_label: ''
      wizard_auto_forward: true
      wizard_auto_forward_hide_next_button: false
      wizard_keyboard: true
      wizard_track: ''
      wizard_prev_button_label: ''
      wizard_next_button_label: ''
      wizard_toggle: false
      wizard_toggle_show_label: ''
      wizard_toggle_hide_label: ''
      wizard_page_type: container
      wizard_page_title_tag: h2
      preview: 0
      preview_label: ''
      preview_title: ''
      preview_message: ''
      preview_attributes: {  }
      preview_excluded_elements: {  }
      preview_exclude_empty: true
      preview_exclude_empty_checkbox: false
      draft: none
      draft_multiple: false
      draft_auto_save: false
      draft_saved_message: ''
      draft_loaded_message: ''
      draft_pending_single_message: ''
      draft_pending_multiple_message: ''
      confirmation_type: page
      confirmation_url: ''
      confirmation_title: ''
      confirmation_message: ''
      confirmation_attributes: {  }
      confirmation_back: true
      confirmation_back_label: ''
      confirmation_back_attributes: {  }
      confirmation_exclude_query: false
      confirmation_exclude_token: false
      confirmation_update: false
      limit_total: null
      limit_total_interval: null
      limit_total_message: ''
      limit_total_unique: false
      limit_user: null
      limit_user_interval: null
      limit_user_message: ''
      limit_user_unique: false
      entity_limit_total: null
      entity_limit_total_interval: null
      entity_limit_user: null
      entity_limit_user_interval: null
      purge: none
      purge_days: null
      results_disabled: false
      results_disabled_ignore: false
      results_customize: false
      token_view: false
      token_update: false
      token_delete: false
      serial_disabled: false
    access:
      create:
        roles:
          - anonymous
          - authenticated
        users: {  }
        permissions: {  }
      view_any:
        roles: {  }
        users: {  }
        permissions: {  }
      update_any:
        roles: {  }
        users: {  }
        permissions: {  }
      delete_any:
        roles: {  }
        users: {  }
        permissions: {  }
      purge_any:
        roles: {  }
        users: {  }
        permissions: {  }
      view_own:
        roles: {  }
        users: {  }
        permissions: {  }
      update_own:
        roles: {  }
        users: {  }
        permissions: {  }
      delete_own:
        roles: {  }
        users: {  }
        permissions: {  }
      administer:
        roles: {  }
        users: {  }
        permissions: {  }
      test:
        roles: {  }
        users: {  }
        permissions: {  }
      configuration:
        roles: {  }
        users: {  }
        permissions: {  }
    handlers: {  }
    variants: {  }
    
  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    532 pass, 2 fail
  • 🇧🇷Brazil elber Brazil

    Hi I just rebased.

  • 🇫🇮Finland phonkala

    @bbombachini I was getting no output of that yaml (well, there was submit button) so checked into it a bit and seems the element types are named differently than mine. Modified the source "elements" section a bit, with this I got composite with checkboxes:

    elements:
      custom_composite_test:
        '#type': custom_composite
        '#title': 'Custom composite test'
        '#element':
          select_options:
            '#type': checkboxes
            '#options':
              test1: 'Test 1'
              test2: 'Test 2'
              test3: 'Test 3'
              test4: 'Test 4'
            '#title': 'Select options'

    And submitting gives no error.

    Basically I just checked the element types from my other forms and replaced the ones you had with them. And also removed the "|-" part from the "elements" row.

  • 🇫🇮Finland phonkala

    @bbombachini Ah now I see it, using "webform_checkboxes_other" as the element type sure does give the array key error! Weirdly, "webform_select_other" works just fine.

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    535 pass, 2 fail
  • 🇺🇸United States jrglasgow Idaho

    The patch in #48 was no longer applying to 6.2.x (Drupal 10 compatible) so I fixed the merge conflict in the fork

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    535 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    535 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 8 months ago
    535 pass, 2 fail
  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    535 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    535 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    534 pass, 2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    536 pass
  • 🇵🇱Poland alorenc Wolsztyn, 🇵🇱

    Fixed issue with "webform_checkboxes_other" and the failing tests.

  • Status changed to Needs review 7 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    535 pass, 2 fail
  • 🇵🇱Poland alorenc Wolsztyn, 🇵🇱
  • The last submitted patch, 63: 3216923--6.2.x--62.patch, failed testing. View results
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    536 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 7 months ago
    536 pass
  • 🇵🇱Poland alorenc Wolsztyn, 🇵🇱

    Rolled patch with the latest updates from merge request

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 5 months ago
    512 pass, 36 fail
Production build 0.69.0 2024