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

Created on 2 October 2022, over 2 years ago
Updated 17 May 2023, almost 2 years 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 almost 2 years 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 almost 2 years ago
  • 🇨🇭Switzerland berdir Switzerland

    Committed.

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

Production build 0.71.5 2024