Array to string conversion in webform/src/Utility/WebformOptionsHelper.php on line 59

Created on 2 October 2022, over 1 year ago
Updated 17 May 2023, about 1 year ago

I got a Array to string conversion in webform/src/Utility/WebformOptionsHelper.php on line 59 error when I tried to add a MailChimp handler to my webform.

Because you are adding a new handler, there isn't a default option other than the select_other option. So I replaced line 128

'#default_value' => $this->configuration['list'],

with

'#default_value' => ($this->configuration['list'] ?: null),

and everything works now.

πŸ› Bug report
Status

Fixed

Version

5.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium Seppe Beelprez

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

Comments & Activities

Not all content is available!

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

  • πŸ‡¨πŸ‡­Switzerland Berdir Switzerland
    +++ b/src/Plugin/WebformHandler/WebformMailChimpHandler.php
    @@ -125,7 +125,7 @@ class WebformMailChimpHandler extends WebformHandlerBase {
           '#empty_option' => $this->t('- Select an option -'),
    -      '#default_value' => $this->configuration['list'],
    +      '#default_value' => ($this->configuration['list'] ?: null),
           '#options' => $options,
    

    The problem is that the default value for list in defaultConfiguration is set to an empty array instead of NULL, change that and it should work.

  • Status changed to Needs review about 1 year ago
  • πŸ‡¨πŸ‡­Switzerland Berdir Switzerland

    Ok, I also understand now that this only happens when your mailchimp account has no list yet, which is quite unusual. And you can't use this module in that scenario, you need a list, the other option still needs to pick a valid list, just dynamically. Either way, the correct default value is NULL indeed.

    • Berdir β†’ committed 94d96bdb on 8.x-5.x
      Issue #3313121 by Seppe Beelprez, Berdir, arti_parmar: Array to string...
  • Status changed to Fixed about 1 year ago
  • πŸ‡¨πŸ‡­Switzerland Berdir Switzerland

    Committed.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024