Answers.Body: <p>If you want to limit your relationships to a particular field, use this syntax:</p>
  
  <pre><code>$criteria-&gt;relatedTo = array(
      'targetElement' =&gt; $element,
      'field' =&gt; $field
  );
  </code></pre>
  
  <p>I believe 'field' will take:</p>
  
  <p>1) A single or array of $field instances</p>
  
  <p>2) A single or array of field IDs or field handles.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-11T00:12:21.657Z
Answers.Text: That did! Appreciate it Brad.
Answers.UserDisplayName: Peter Tell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-10T23:39:16.923Z
Answers.LastActivityDate: 2014-07-10T23:39:16.923Z
Answers.UserDisplayName: Brad Bell
Body: <p>So,</p>
  
  <p>I want to grab all entries that are related to an entry but with the following criteria:</p>
  
  <ol>
  <li>Only from my section ($section)</li>
  <li>Only the ones that have been added to a certain field ($fieldId)</li>
  </ol>
  
  <p>I currently have this:</p>
  
  <pre><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
  $criteria-&gt;section = $section;
  $criteria-&gt;limit   = null;
  $criteria-&gt;relatedTo = array(
      'targetElement' =&gt; $element,
  );
  $elements = craft()-&gt;elements-&gt;findElements($criteria);
  return $elements;
  </code></pre>
  
  <p>But if I add two relationship fields to an entry, this will return ALL the associated entries from either field. I want to limit it to just the entries attached to the one field.</p>
  
  <p>Is this possible? Does the question make sense? :-)</p>
  
Tags: <plugin-development>
Title: Is it possible to grab related entries that have been attached to a certain field?
ThreadText: # Is it possible to grab related entries that have been attached to a certain field?
  
  (Asked by: username_0 on 2014-07-10)
  
  So,
  
  I want to grab all entries that are related to an entry but with the following criteria:
  
  1. Only from my section ($section)
  2. Only the ones that have been added to a certain field ($fieldId)
  
  I currently have this:
  
  ```
  $criteria = craft()->elements->getCriteria(ElementType::Entry);
  $criteria->section = $section;
  $criteria->limit   = null;
  $criteria->relatedTo = array(
      'targetElement' => $element,
  );
  $elements = craft()->elements->findElements($criteria);
  return $elements;
  
  ```
  
  But if I add two relationship fields to an entry, this will return ALL the associated entries from either field. I want to limit it to just the entries attached to the one field.
  
  Is this possible? Does the question make sense? :-)
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-07-10. Score: 4 | Accepted answer
  
  If you want to limit your relationships to a particular field, use this syntax:
  
  ```
  $criteria->relatedTo = array(
      'targetElement' => $element,
      'field' => $field
  );
  
  ```
  
  I believe 'field' will take:
  
  1) A single or array of $field instances
  
  2) A single or array of field IDs or field handles.
  
  > **Comments:**
  > **username_0**: That did! Appreciate it username_1.  
  
  ---
  
  