<p>After experimenting with syntax a bit I made it work, looks like it needs an id, but it doesn't work with the event as an object.</p>

<p>So this works:</p>

<pre><code>{% set reviews = craft.entries.section('reviews').relatedTo(event.id) %}
</code></pre>

CC BY-SA 4.0
2018-06-20T07:23:18.513Z
2018-06-20T07:23:18.513Z
Lukigi
<p>You can use them the same way like you are used to everywhere else. All relation fields extend the same <code>BaseRelationField</code> so their logic is totally equal.</p>

<p>You can either pass an element, an element id or an <code>ElementQuery</code>/<code>ElementCriteriaModel</code> but not a string to the function. If you want to fetch all related elements of an event you'll need to fetch the event first </p>

CC BY-SA 4.0
2018-06-20T06:16:15.857Z
Apologies made a syntax error here on Stack, yes I'm passing the event object to the realtedTo(), the event is there and so are reviews, but they are not fetched
Lukigi
CC BY-SA 4.0
2018-06-20T06:26:14.547Z
Is the code now the code you use? Because `search` is totally wrong. If you use Craft 2 you need to execute `find()` if you use Craft 3 `all()`
Robin Schambach
CC BY-SA 4.0
2018-06-20T06:26:21.377Z
In fact, I use exactly the same code on a standard entry, as I have reviews for more than events and it works fine.
Lukigi
CC BY-SA 4.0
2018-06-20T06:28:06.767Z
I've been trying with and without find() not working either
Lukigi
CC BY-SA 4.0
2018-06-20T06:30:21.367Z
There must be an error in your structure or something because the code is correct. Maybe some events are disabled or don't fulfill status conditions
Robin Schambach
CC BY-SA 4.0
2018-06-20T06:36:53.930Z
No event is there, Im displaying other information successfully, reviews are there as well I've checked multiple times, and they are enabled.
Lukigi
CC BY-SA 4.0
2018-06-19T20:59:46.207Z
2018-06-19T20:59:46.207Z
Robin Schambach
<p>I'm using Solspace Calendar for events, I also have a standard channel for reviews. What I need is the ability to connect the review with the event. </p>

<p>Solspace offers "Calendar Events" custom type field to do that, however, when I use it and attach an event to it this code:</p>

<pre><code>{% set reviews = craft.entries.section('reviews').relatedTo(event) %}
{% if reviews|length %}
   {% for review in reviews %}
      &lt;h5&gt;{{review.title}}&lt;/h5&gt;
      &lt;p&gt;{{review.description|nl2br}}&lt;/p&gt;
   {% endfor %}
{% else %}
   &lt;p&gt;There are no reviews yet&lt;/p&gt;
{% endif %}
</code></pre>

<p>isn't working, and I have the same code working for a standard entry. How do I use relatedTo on custom fields?</p>

<p>This works on a different page with entry present</p>

<pre><code>{% set reviews = craft.entries.section('reviews').relatedTo(entry) %}
</code></pre>

<p>This doens't work when event present</p>

<pre><code>{% set reviews = craft.entries.section('reviews').relatedTo(event) %}
</code></pre>

<p>I've made sure that: </p>

<ul>
<li>the event is fetched, and I'm successfully accessing it via code above</li>
<li>there are indeed reviews with this event attached
<a href="https://i.sstatic.net/fijv6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fijv6.png" alt="reviews in admin"></a></li>
</ul>

<relations><solspace><plugin-solspacecalendar>
Relating to Solspace Calendar Events
# Relating to Solspace Calendar Events

(Asked by: username_0 on 2018-06-19)

I'm using Solspace Calendar for events, I also have a standard channel for reviews. What I need is the ability to connect the review with the event. 
Solspace offers "Calendar Events" custom type field to do that, however, when I use it and attach an event to it this code:
{% set reviews = craft.entries.section('reviews').relatedTo(event) %}
{% if reviews|length %}
   {% for review in reviews %}
      {{review.title}}
      {{review.description|nl2br}}
   {% endfor %}
{% else %}
   There are no reviews yet
{% endif %}

isn't working, and I have the same code working for a standard entry. How do I use relatedTo on custom fields?
This works on a different page with entry present
{% set reviews = craft.entries.section('reviews').relatedTo(entry) %}

This doens't work when event present
{% set reviews = craft.entries.section('reviews').relatedTo(event) %}

I've made sure that: 

the event is fetched, and I'm successfully accessing it via code above
there are indeed reviews with this event attached

**Tags:** relations, solspace, plugin-solspacecalendar


---

## 2 answers

### Answer by username_0 on 2018-06-20. Score: 1

After experimenting with syntax a bit I made it work, looks like it needs an id, but it doesn't work with the event as an object.
So this works:
{% set reviews = craft.entries.section('reviews').relatedTo(event.id) %}


---

### Answer by username_1 on 2018-06-19. Score: 1

You can use them the same way like you are used to everywhere else. All relation fields extend the same `BaseRelationField` so their logic is totally equal.

You can either pass an element, an element id or an `ElementQuery`/`ElementCriteriaModel` but not a string to the function. If you want to fetch all related elements of an event you'll need to fetch the event first

> **Comments:**
> **username_0**: Apologies made a syntax error here on Stack, yes I'm passing the event object to the realtedTo(), the event is there and so are reviews, but they are not fetched  
> **username_1**: Is the code now the code you use? Because `search` is totally wrong. If you use Craft 2 you need to execute `find()` if you use Craft 3 `all()`  
> **username_0**: In fact, I use exactly the same code on a standard entry, as I have reviews for more than events and it works fine.  
> **username_0**: I've been trying with and without find() not working either  
> **username_1**: There must be an error in your structure or something because the code is correct. Maybe some events are disabled or don't fulfill status conditions  
> **username_0**: No event is there, Im displaying other information successfully, reviews are there as well I've checked multiple times, and they are enabled.  

---

