Subcategories

default discord avatar
digimortal_
10 months ago
3

Moving over from #general where it was recommended to use a

parent

field to the

categories

collection, which is a

relation

to the collection itself to add subcategories. While this would work, it would be quite confusing within the UI itself, right, as editors would not be easily able to determine which are subcategories and which top-level categories they belong to (from the main collection screen).

  • default discord avatar
    jarrod69420
    10 months ago

    You could either add another field to denote the type (top-level/sub) or create an entirely different collection for sub categories. Both would be fine approaches.

  • default discord avatar
    Gaurav
    3 months ago

    i have same problem I am using payloadcms and in collection of posts I have


    {


    name: "category",


    type: "relationship",


    relationTo: "categories",


    required:true


    }, this category field , now I want to include subcategories field but it should show subcategories only from array which is present in selected category



    I have subcategories collection from that collection only I am currently getting subcategories using relationship but now I want subcategories according to selection of category can you please help or guide with this



    My question is i have collection categories and collection subctegories, in categories collection i added subcategories throughe relationship, so while creating any post i need that my subcategories should populate in option depending upon selection of cetegory.But i am not able to do that so please help me with that

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.