2

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!

2

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.

  • 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 Oct 2 '17 at 18:10
  • James, would you mind throwing this modified field type on a public repo somewhere? – Chase Giunta Oct 11 '17 at 21:49
  • @James, do you have the modified fieldtype you could post somewhere? Thanks. – Erik Aug 15 '18 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.