Answers.Body: <p>When you are going to apply an <code>and</code> in your <code>relatedTo</code> in Craft 3 it expects the following arguments to be arrays with the structure like <a href="https://docs.craftcms.com/v2/relations.html#passing-multiple-relation-criteria" rel="nofollow noreferrer">here</a> </p>
  
  <pre><code>{% set entries = craft
      .entries
      .section('institutions')
      .relatedTo(['and', 
          {element: state}, // &lt;- or targetElement / sourceElement
          {element: solution}
      ])
      .limit(4) 
      .all()
  %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-22T07:57:30.700Z
Answers.Text: You saved me with the `{element: variable}` syntax. Where did you learn that from? I can't find syntax like that anywhere in the docs.
Answers.UserDisplayName: Brimby
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-23T13:01:02.307Z
Answers.Text: @Brimby it's in the documentation I linked in my post
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-04T20:51:08.323Z
Answers.LastActivityDate: 2018-04-04T20:51:08.323Z
Answers.UserDisplayName: Robin Schambach
Body: <p>Here we go:</p>
  
  <pre><code>{% set state = craft.categories.group('locations').level(1).title(entry.title).one() %}
  {% set solution = craft.categories.group('institutionSolutions').title(entry.parent.title).one() %}
  {% set entries = craft.entries.section('institutions').relatedTo('and', state, solution).limit(4) %}
  
     {% for entry in entries %}
         {{ entry.title }}
     {% endfor %}
  </code></pre>
  
  <p>The following code does work as expected in Craft 2. According to the docs in Craft 3 we have to use the array brackets. So this</p>
  
  <pre><code>{% set entries = craft.entries.section('institutions').relatedTo('and', state, solution).limit(4) %}
  </code></pre>
  
  <p>will become to this</p>
  
  <pre><code>{% set entries = craft.entries.section('institutions').relatedTo(['and', state, solution).limit(4) %}
  </code></pre>
  
  <p>as a result I see the following message:</p>
  
  <p>array_merge(): Argument #2 is not an array</p>
  
  <p>What am I doing wrong? :(</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-04-04T17:45:50.673Z
Comments.Text: You're missing a closing square bracket fyi...
Comments.UserDisplayName: Jalen Davenport
Tags: <craft3><array>
Title: Argument #2 is not an array
ThreadText: # Argument #2 is not an array
  
  (Asked by: username_0 on 2018-04-04)
  
  Here we go:
  
  ```
  {% set state = craft.categories.group('locations').level(1).title(entry.title).one() %}
  {% set solution = craft.categories.group('institutionSolutions').title(entry.parent.title).one() %}
  {% set entries = craft.entries.section('institutions').relatedTo('and', state, solution).limit(4) %}
  
     {% for entry in entries %}
         {{ entry.title }}
     {% endfor %}
  
  ```
  
  The following code does work as expected in Craft 2. According to the docs in Craft 3 we have to use the array brackets. So this
  
  ```
  {% set entries = craft.entries.section('institutions').relatedTo('and', state, solution).limit(4) %}
  
  ```
  
  will become to this
  
  ```
  {% set entries = craft.entries.section('institutions').relatedTo(['and', state, solution).limit(4) %}
  
  ```
  
  as a result I see the following message:
  
  array\_merge(): Argument #2 is not an array
  
  What am I doing wrong? :(
  
  **Tags:** craft3, array
  
  > **Comments:**
  > **username_1**: You're missing a closing square bracket fyi...  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-04-04. Score: 1 | Accepted answer
  
  When you are going to apply an `and` in your `relatedTo` in Craft 3 it expects the following arguments to be arrays with the structure like [here](https://docs.craftcms.com/v2/relations.html#passing-multiple-relation-criteria)
  
  ```
  {% set entries = craft
      .entries
      .section('institutions')
      .relatedTo(['and', 
          {element: state}, // <- or targetElement / sourceElement
          {element: solution}
      ])
      .limit(4) 
      .all()
  %}
  
  ```
  
  > **Comments:**
  > **username_3**: You saved me with the `{element: variable}` syntax. Where did you learn that from? I can't find syntax like that anywhere in the docs.  
  > **username_2**: @username_3 it's in the documentation I linked in my post  
  
  ---
  
  