Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-20T07:23:18.513Z
Answers.LastActivityDate: 2018-06-20T07:23:18.513Z
Answers.UserDisplayName: Lukigi
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-20T06:16:15.857Z
Answers.Text: 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
Answers.UserDisplayName: Lukigi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-20T06:26:14.547Z
Answers.Text: 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()`
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-20T06:26:21.377Z
Answers.Text: In fact, I use exactly the same code on a standard entry, as I have reviews for more than events and it works fine.
Answers.UserDisplayName: Lukigi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-20T06:28:06.767Z
Answers.Text: I've been trying with and without find() not working either
Answers.UserDisplayName: Lukigi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-20T06:30:21.367Z
Answers.Text: 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
Answers.UserDisplayName: Robin Schambach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-20T06:36:53.930Z
Answers.Text: No event is there, Im displaying other information successfully, reviews are there as well I've checked multiple times, and they are enabled.
Answers.UserDisplayName: Lukigi
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-19T20:59:46.207Z
Answers.LastActivityDate: 2018-06-19T20:59:46.207Z
Answers.UserDisplayName: Robin Schambach
Body: <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>
  
Tags: <relations><solspace><plugin-solspacecalendar>
Title: Relating to Solspace Calendar Events
ThreadText: # 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 %}
        <h5>{{review.title}}</h5>
        <p>{{review.description|nl2br}}</p>
     {% endfor %}
  {% else %}
     <p>There are no reviews yet</p>
  {% 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
    [![reviews in admin](https://i.sstatic.net/fijv6.png)](https://i.sstatic.net/fijv6.png)
  
  **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.  
  
  ---
  
  