<p>I managed to workaround this by creating my own custom fieldtype which is 99% the code from the Craft CategoriesFieldType, but with the only difference being I removed the call to <code>craft()-&gt;categories-&gt;fillGapsInCategoryIds($categoryIds)</code>.</p>

<p>This works but I've yet to see if it causes any side-effects I need to worry about.</p>

CC BY-SA 3.0
2017-10-02T18:10:56.427Z
FWIW, this is solved in the upcoming Craft 3 with the concept of category field branch limits.  Allows you to set how far up the category tree to select (if at all).
Brad Bell
CC BY-SA 3.0
2017-10-11T21:49:13.987Z
James, would you mind throwing this modified field type on a public repo somewhere?
Chase Giunta
CC BY-SA 4.0
2018-08-15T14:43:58.947Z
@James, do you have the modified fieldtype you could post somewhere? Thanks.
Erik
CC BY-SA 3.0
2017-10-02T11:16:07.993Z
2017-10-02T18:07:33.307Z
2017-10-02T18:07:33.307Z
James
<p>When adding a Categories field to a section, if you select only child categories, Craft automatically selects the parent categories too. I emailed Craft support about this and they explained it's by design and the workaround is to use a Structure instead of Categories.</p>

<p>I'm unhappy with this as a workaround and was hoping their was another way to do this, either with a custom plugin or something else?</p>

<p>Any help much appreciated</p>

<p>Thanks! </p>

<categories><relations>
Associate child categories only to an entry
# Associate child categories only to an entry

(Asked by: username_0 on 2017-10-02)

When adding a Categories field to a section, if you select only child categories, Craft automatically selects the parent categories too. I emailed Craft support about this and they explained it's by design and the workaround is to use a Structure instead of Categories.

I'm unhappy with this as a workaround and was hoping their was another way to do this, either with a custom plugin or something else?

Any help much appreciated

Thanks!

**Tags:** categories, relations

---

## 1 answers

### Answer by username_0 on 2017-10-02. Score: 2 | Accepted answer

I managed to workaround this by creating my own custom fieldtype which is 99% the code from the Craft CategoriesFieldType, but with the only difference being I removed the call to `craft()->categories->fillGapsInCategoryIds($categoryIds)`.

This works but I've yet to see if it causes any side-effects I need to worry about.

> **Comments:**
> **username_1**: FWIW, this is solved in the upcoming Craft 3 with the concept of category field branch limits.  Allows you to set how far up the category tree to select (if at all).  
> **username_2**: James, would you mind throwing this modified field type on a public repo somewhere?  
> **username_3**: @James, do you have the modified fieldtype you could post somewhere? Thanks.  

---

