Answers.Body: <p>In case of the element type <code>Asset</code> sources are the available volumes. In case of <code>Category</code> the available sources are the different groups. Sources for <code>Entry</code> are your sections, <code>Tag</code> have the different sets/groups as well.</p>
  
  <p>It contains an array or the type <code>section</code>, <code>folder</code>, <code>group</code> and the ID of the corresponding model, separated with an <code>:</code></p>
  
  <p>You can just do </p>
  
  <pre><code>$field = Craft::$app-&gt;getFields()-&gt;getFieldById(&gt;&gt;your field id&lt;&lt;);
  Craft::dd($field-&gt;sources);
  </code></pre>
  
  <p>to get to know how it looks like. It could be like this:</p>
  
  <pre><code>array(1) {
    [0]=&gt; string(10) "section:16"
    [1]=&gt; string(10) "section:18"
  }
  </code></pre>
  
  <p>or for an <code>Asset</code></p>
  
  <pre><code>array(1) {
    [0]=&gt; string(8) "folder:1"
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-24T06:08:42.780Z
Answers.LastActivityDate: 2018-04-24T06:08:42.780Z
Answers.UserDisplayName: Robin Schambach
Body: <p>I see the following in BaseRelationField:</p>
  
  <pre><code>public function settingsAttributes(): array
  {
      $attributes = parent::settingsAttributes();
      $attributes[] = 'sources';
      $attributes[] = 'source';
      $attributes[] = 'targetSiteId';
      $attributes[] = 'viewMode';
      $attributes[] = 'limit';
      $attributes[] = 'selectionLabel';
      $attributes[] = 'localizeRelations';
  
      return $attributes;
  }
  </code></pre>
  
  <p>The comments for the properties say:</p>
  
  <pre><code>   /**
       * @var string|string[]|null The source keys that this field can relate elements from (used if [[allowMultipleSources]] is set to true)
       */
      public $sources = '*';
  
      /**
       * @var string|null The source key that this field can relate elements from (used if [[allowMultipleSources]] is set to false)
       */
      public $source;
  </code></pre>
  
  <p>In the case of the single source. What would that string look like? What is that string referring to? A table name? In ID in a particular table?</p>
  
  <p>Looks like the BaseRelationField is extended by Entries field and Users field and the sources are Entry structures and Administration groups respectively. If I wanted to set one as s static value what would that be?</p>
  
Tags: <plugin-development><relations><custom-fieldtype>
Title: What is $source and $sources in BaseRelationField?
ThreadText: # What is $source and $sources in BaseRelationField?
  
  (Asked by: username_0 on 2018-04-24)
  
  I see the following in BaseRelationField:
  
  ```
  public function settingsAttributes(): array
  {
      $attributes = parent::settingsAttributes();
      $attributes[] = 'sources';
      $attributes[] = 'source';
      $attributes[] = 'targetSiteId';
      $attributes[] = 'viewMode';
      $attributes[] = 'limit';
      $attributes[] = 'selectionLabel';
      $attributes[] = 'localizeRelations';
  
      return $attributes;
  }
  
  ```
  
  The comments for the properties say:
  
  ```
     /**
       * @var string|string[]|null The source keys that this field can relate elements from (used if [[allowMultipleSources]] is set to true)
       */
      public $sources = '*';
  
      /**
       * @var string|null The source key that this field can relate elements from (used if [[allowMultipleSources]] is set to false)
       */
      public $source;
  
  ```
  
  In the case of the single source. What would that string look like? What is that string referring to? A table name? In ID in a particular table?
  
  Looks like the BaseRelationField is extended by Entries field and Users field and the sources are Entry structures and Administration groups respectively. If I wanted to set one as s static value what would that be?
  
  **Tags:** plugin-development, relations, custom-fieldtype
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-04-24. Score: 1 | Accepted answer
  
  In case of the element type `Asset` sources are the available volumes. In case of `Category` the available sources are the different groups. Sources for `Entry` are your sections, `Tag` have the different sets/groups as well.
  
  It contains an array or the type `section`, `folder`, `group` and the ID of the corresponding model, separated with an `:`
  
  You can just do
  
  ```
  $field = Craft::$app->getFields()->getFieldById(>>your field id<<);
  Craft::dd($field->sources);
  
  ```
  
  to get to know how it looks like. It could be like this:
  
  ```
  array(1) {
    [0]=> string(10) "section:16"
    [1]=> string(10) "section:18"
  }
  
  ```
  
  or for an `Asset`
  
  ```
  array(1) {
    [0]=> string(8) "folder:1"
  }
  
  ```
  
  
  ---
  
  