Search code examples
strapi

Is it possible to have conditional content field in Strapi?


How to add a conditional field in Strapi?

I want to have a conditional field, which will only appear if the boolean field is true

For example;

Dog content type has a Boolean field (asking if the dog has a beard), if it does then It asks for the color of it.


viewColorField = (beardStatus == TRUE)? TRUE : FALSE;

condional fields

Is it possible in Strapi admin area or should I solve it frontend?

I am using Strapi v3.0.0-beta.

Thanks for your answers in advance.


Solution

  • This option doesn't exist by default in Strapi.

    If you want your can try to customize the admin panel to match your need.

    To do that you will have to read and understand some concept / code base of Strapi.

    This will let you update the admin panel of a plugin, in your case, the content manager plugin.

    I suggest you to check this source code, find where the Edit View container is managed.

    Then customize it to add a condition for your specific Content Type and Field.

    This will be a little bit tricky but it's possible to achieve your goal.