<p>You could use entries instead of categories. Create four structures and use them instead of your category groups. Your category field will actually be an entry field, and it can pull from the four structures, with a limit of one.</p>

CC BY-SA 3.0
2015-09-08T18:52:11.260Z
2015-09-08T18:52:11.260Z
Marion Newlevant
<p>You cannot allow selection from multiple category sources in a category field.</p>

<p>I would keep the 4 category fields but set each field to limit to one (1) category selection.</p>

<p>Then, when you add the field to the field layout, make the field required to ensure they select a category for each field.</p>

CC BY-SA 3.0
2015-09-08T16:19:32.663Z
Hi Luke, thanks for helping out.  The trouble with that is that only want 1 field out of the 4 to have input. and the other 3 empty.  ie. a total of 1 category selected across the 4 fields rather than 1 category selected for each field.
Tchick
CC BY-SA 3.0
2015-09-08T15:34:38.613Z
2015-09-08T15:34:38.613Z
Luke Holder
<p>What are your 4 sources used for?  Depending on your content you might be able to work around it. </p>

<p>There's no exact science to this but in my experience doing IA, here's a few thoughts on category sources:</p>

<ul>
<li><p>I like to set mine up so they kind of match the sections I'm posting in.  If you have to reach across multiple category <em>sources</em> for a field—say you only have one section throughout the site—it's possible your top level sections aren't specific enough. </p></li>
<li><p>You might be using categories that really shouldn't be categories.  Like on a news site, Breaking News could very well span across everything. In that case, you'd be better off setting up a new field, say a checkbox, and allowing your authors to tick it as appropriate. </p></li>
<li><p>If you're coming from something like WordPress where you <em>only</em> had
categories and tags to use out of the box, you can fall in that trap.
Along the same lines,  if you wanted to put something on the home page, you might have used a "featured" category that only shows up on the home page; a better, Craftier way is to use its relational magic and setup a field on the home page entry itself.</p></li>
<li><p>Category sources are hierarchical so you could merge the ones you need into some kind of catch-all category as needed. Categories should be relatively shallow. If you have like 50 categories for a smaller site, you're doing it wrong. It sounds like you have categories that are of varying topics.  That can be a nightmare anyway you slice it. </p></li>
</ul>

<p>As Luke mentioned, you can set it up so only 1 category can be selected. I would also look at how your 4 category fields are labeled. If you have labels like "Main Category" and then "Sub Category", it's probably OK that someone leaves the second and 3rd fields blank, for example. So the first could be required as a general "gist" of what the topic is, more less drilling down specificity.</p>

CC BY-SA 3.0
2015-09-08T16:22:03.697Z
Hi, thanks for your helpful and considered answer.  The scenario is a shop whereby we're using categories to assign "collections" of products, admin specified "price bands", "lead-in time" and type of product. Each is a category that is also used as a filter mechanism on the front end. 
We're building a landing page for the shop with UI elements that link through to category pages - whether that's a "price-band", "type of product" page etc.
Tchick
CC BY-SA 3.0
2015-09-08T16:25:49.573Z
We want the admin to be able to specify which category the panel links through to - which means selecting from a category field type, but ideally from the 4 sources not just one. Hence the tangle.
In your first point I think you mean that I should try lumping related category sources in a single parent category and then specifying that as the source?  That could work...
Tchick
CC BY-SA 3.0
2015-09-08T22:32:26.833Z
Yeh exactly.  Twig and Craft is extremely flexible when it comes to relationships so whatever you decide to do you can likely make it work with the right query.
RitterKnight
CC BY-SA 3.0
2015-09-08T16:02:36.940Z
2015-09-08T16:02:36.940Z
RitterKnight
<p>We're trying to setup a category field type to allow the selection of 1 category but from multiple category sources. Is there a simple way to achieve this without writing a custom plugin / fieldtype?</p>

<p>Currently we've set up 4 Category fields to allow a selection from the 4 sources with instructions to only use one of these fields at a time but it feels messy.  Thanks!</p>

<categories><fieldtypes><category><sources>
Multiple sources on category field type - possible?
# Multiple sources on category field type - possible?

(Asked by: username_0 on 2015-09-08)

We're trying to setup a category field type to allow the selection of 1 category but from multiple category sources. Is there a simple way to achieve this without writing a custom plugin / fieldtype?

Currently we've set up 4 Category fields to allow a selection from the 4 sources with instructions to only use one of these fields at a time but it feels messy. Thanks!

**Tags:** categories, fieldtypes, category, sources

---

## 3 answers

### Answer by username_1 on 2015-09-08. Score: 1 | Accepted answer

You could use entries instead of categories. Create four structures and use them instead of your category groups. Your category field will actually be an entry field, and it can pull from the four structures, with a limit of one.


---

### Answer by username_2 on 2015-09-08. Score: 1

You cannot allow selection from multiple category sources in a category field.

I would keep the 4 category fields but set each field to limit to one (1) category selection.

Then, when you add the field to the field layout, make the field required to ensure they select a category for each field.

> **Comments:**
> **username_0**: Hi Luke, thanks for helping out.  The trouble with that is that only want 1 field out of the 4 to have input. and the other 3 empty.  ie. a total of 1 category selected across the 4 fields rather than 1 category selected for each field.  

---

### Answer by username_3 on 2015-09-08. Score: 1

What are your 4 sources used for? Depending on your content you might be able to work around it.

There's no exact science to this but in my experience doing IA, here's a few thoughts on category sources:

* I like to set mine up so they kind of match the sections I'm posting in. If you have to reach across multiple category *sources* for a field—say you only have one section throughout the site—it's possible your top level sections aren't specific enough.
* You might be using categories that really shouldn't be categories. Like on a news site, Breaking News could very well span across everything. In that case, you'd be better off setting up a new field, say a checkbox, and allowing your authors to tick it as appropriate.
* If you're coming from something like WordPress where you *only* had
  categories and tags to use out of the box, you can fall in that trap.
  Along the same lines, if you wanted to put something on the home page, you might have used a "featured" category that only shows up on the home page; a better, Craftier way is to use its relational magic and setup a field on the home page entry itself.
* Category sources are hierarchical so you could merge the ones you need into some kind of catch-all category as needed. Categories should be relatively shallow. If you have like 50 categories for a smaller site, you're doing it wrong. It sounds like you have categories that are of varying topics. That can be a nightmare anyway you slice it.

As Luke mentioned, you can set it up so only 1 category can be selected. I would also look at how your 4 category fields are labeled. If you have labels like "Main Category" and then "Sub Category", it's probably OK that someone leaves the second and 3rd fields blank, for example. So the first could be required as a general "gist" of what the topic is, more less drilling down specificity.

> **Comments:**
> **username_0**: Hi, thanks for your helpful and considered answer.  The scenario is a shop whereby we're using categories to assign "collections" of products, admin specified "price bands", "lead-in time" and type of product. Each is a category that is also used as a filter mechanism on the front end.  We're building a landing page for the shop with UI elements that link through to category pages - whether that's a "price-band", "type of product" page etc.  
> **username_0**: We want the admin to be able to specify which category the panel links through to - which means selecting from a category field type, but ideally from the 4 sources not just one. Hence the tangle. In your first point I think you mean that I should try lumping related category sources in a single parent category and then specifying that as the source?  That could work...  
> **username_3**: Yeh exactly.  Twig and Craft is extremely flexible when it comes to relationships so whatever you decide to do you can likely make it work with the right query.  

---

