question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running into "array_merge(): Argument #2 is not an array" on re-render

See original GitHub issue

Describe the bug

Trying to use Sprig with the mailchimp-subscribe plugin.

Expected behaviour

The submission works but I think when Sprig tries to re-render it hits an error.

Screenshots

Screen Shot 2020-09-10 at 11 48 15 AM

Versions

  • Plugin version: 1.0.0-beta.13
  • Craft version: 3.5.8

Here is what our component looks like:

{% set subscribeResponse = 
  mailchimpSubscribe is defined
  and mailchimpSubscribe.action == 'subscribe'
  ? mailchimpSubscribe : null %}

{% if subscribeResponse and subscribeResponse.success %}
  <p>You’ve been subscribed!</button>
{% else %}
  <form
    class="newsletter-form"
    sprig
    s-method="post"
    s-action="mailchimp-subscribe/audience/subscribe">
    {{ csrfInput() }}

    {% if subscribeResponse and not subscribeResponse.success %}
      <p>An error occured: {{ subscribeResponse.message }}</p>
    {% endif %}

    <label for="first_name">First Name</label>
    <input
      type="text"
      name="merge_fields[FNAME]"
      placeholder="First Name"
      {% if subscribeResponse and not subscribeResponse.success %}value="{{ subscribeResponse.values.FNAME ?? '' }}"{% endif %}
      />

    <label for="last_name">Last Name</label>
    <input
      type="text"
      name="merge_fields[LNAME]"
      placeholder="Last Name"
      {% if subscribeResponse and not subscribeResponse.success %}value="{{ subscribeResponse.values.LNAME ?? '' }}"{% endif %}
      />

    <label for="email"{% if subscribeResponse and subscribeResponse.errorCode=='1000' %} class="error"{% endif %}>Email:</label>
    <input
      id="email"
      type="text"
      name="email"
      placeholder="Email"
      {% if subscribeResponse and not subscribeResponse.success %}value="{{ subscribeResponse.values.email ?? '' }}"{% endif %}
      required
      />

    <button type="submit" class="btn">
      Join the Newsletter!¡
    </button>
  </form>
{% endif %}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
codyjamescommented, Sep 11, 2020

Seems to be working just great. Thanks for your fast response time on this!

0reactions
codyjamescommented, Sep 11, 2020

Great, I’ll try that out! Sorry I couldn’t be more helpful in debugging this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "array_merge argument is not an array"?
I'm trying to resolve it but I'm not sure what else to try. Here is the code that I an executing: $config =...
Read more >
Fatal Core Error when updating to PHP8
Running WP 6.03 Switched from PHP7.4 to PHP8.0 and get “WordPress Critical ... TypeError: array_merge(): Argument #2 must be of type array, null...
Read more >
Vuex add item to array
It's based on a very simple idea that manages an array (or Vuex store optionally) with multiple loading states. users = Object.
Read more >
PHP array_merge() Function
PHP array_merge() Function ; Merge two arrays into one array: · $a1= ; Merge two associative arrays into one array: · $a1= ·...
Read more >
array_merge - Manual
arrays. Variable list of arrays to merge. ... If called without any arguments, returns an empty array. ... Example #2 Simple array_merge() example....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found