Answers.Body: <p>From the FieldModel you need to get the FieldTypeModel and then its settings. Something like this:</p>
  
  <pre><code>$settings = $field–&gt;getFieldType()-&gt;getSettings();
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-28T23:16:27.123Z
Answers.LastActivityDate: 2017-11-28T23:16:27.123Z
Answers.UserDisplayName: carlcs
Body: <p>I'm writing a plugin that works with Fields in various ways, one thing I need to do is get the category source groups available to a particular category field. I have the field's handle and id and can get it's <code>FieldModel</code> instance from that. But that fieldModel doesn't appear to have any information about what sources it is using.</p>
  
  <p>So for example, I have a Category field named 'peopleClassification', and it has the category group 'peopleWhoWorkHere' as it's source set in the field settings page.</p>
  
  <p>When I inspect the FieldModel object for the peopleClassification field, I'd expect to see the id or handle for the peopleWhoWorkHere group somewhere inside the object. I'm dumping the variables and checking the API docs, and I don't see a way to do that.</p>
  
  <p>I thought that the CategoriesService might have a method for returning sources for a given field ID, but I couldn't find anything.</p>
  
  <p>Does anyone have suggestions on where in the API I can connect these two? It's obviously possible, else Craft wouldn't work at all.</p>
  
  <p>To clarify, I'm not working with specific entry objects here, I'm trying to match field handles to group handles.</p>
  
  <p>@carlcs answer got me to the info I needed (thanks). Here's how I completed it.</p>
  
  <p><code>$field-&gt;getFieldType()-&gt;getSettings()</code> returns an array with various pieces of meta data including a <code>source</code> field with a value like <code>group:42</code>. That number is the category group ID I needed to create an instance of category group object.</p>
  
  <pre><code>list($type, $gid) = split(':', $field-&gt;getFieldType()-&gt;getSettings()['source']);
  </code></pre>
  
  <p>Then use $gid to load an instance of the Group from categories service</p>
  
  <pre><code>$categoryGroup = craft()-&gt;categories-&gt;getGroupById($gid);
  </code></pre>
  
  <p><code>$categoryGroup</code> contained the info I needed, including the group's handle, which I used to create a list of categories.</p>
  
Tags: <plugin-development><categories><fieldtypes>
Title: Plugin Development: find source group used by field
ThreadText: # Plugin Development: find source group used by field
  
  (Asked by: username_0 on 2017-11-28)
  
  I'm writing a plugin that works with Fields in various ways, one thing I need to do is get the category source groups available to a particular category field. I have the field's handle and id and can get it's `FieldModel` instance from that. But that fieldModel doesn't appear to have any information about what sources it is using.
  
  So for example, I have a Category field named 'peopleClassification', and it has the category group 'peopleWhoWorkHere' as it's source set in the field settings page.
  
  When I inspect the FieldModel object for the peopleClassification field, I'd expect to see the id or handle for the peopleWhoWorkHere group somewhere inside the object. I'm dumping the variables and checking the API docs, and I don't see a way to do that.
  
  I thought that the CategoriesService might have a method for returning sources for a given field ID, but I couldn't find anything.
  
  Does anyone have suggestions on where in the API I can connect these two? It's obviously possible, else Craft wouldn't work at all.
  
  To clarify, I'm not working with specific entry objects here, I'm trying to match field handles to group handles.
  
  @username_1 answer got me to the info I needed (thanks). Here's how I completed it.
  
  `$field->getFieldType()->getSettings()` returns an array with various pieces of meta data including a `source` field with a value like `group:42`. That number is the category group ID I needed to create an instance of category group object.
  
  ```
  list($type, $gid) = split(':', $field->getFieldType()->getSettings()['source']);
  
  ```
  
  Then use $gid to load an instance of the Group from categories service
  
  ```
  $categoryGroup = craft()->categories->getGroupById($gid);
  
  ```
  
  `$categoryGroup` contained the info I needed, including the group's handle, which I used to create a list of categories.
  
  **Tags:** plugin-development, categories, fieldtypes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-11-28. Score: 1 | Accepted answer
  
  From the FieldModel you need to get the FieldTypeModel and then its settings. Something like this:
  
  ```
  $settings = $field–>getFieldType()->getSettings();
  
  ```
  
  
  ---
  
  