Required fields depending on a field

Hi! in my project I have a collection called Portfolio Templates, which one of its fields is type. I would like to know if it is possible to implement that when creating a portfolio template, depending on what type is chosen, some fields become mandatory.

For example, if type is A, the name field will be required to create the portfolio template, but if type is B, this field is not required but the description field is required.

Is it possible to achieve this?

I keep waiting for comments,
Thanks!

Hello @usr1vang,

There is several way to achieve this. One way could be to create custom create page for your types (using 2 collections one for each type). See this documentation related to customisation

You can also achieve this by creating smart action with dynamic fields.

Tell if it suits your needs.

Kind regards,
Morgan

Thanks for your answer. I am having problems with the smart actions, its set as visible on forest admin panel but not display on actions.

Hey @usr1vang,

You have to go to the collections settings and check the Make Smart action visible button.

image

You can find more information here on how to create/setup a smart action. :slight_smile:

Kind regards,
Morgan

Yes, it is check. But it is still not displaying the action, that’s why I asked, it’s a bit strange…

What’s the type of your smart action ? single, bulk, global ? Be careful, the smart actions are not all display at the global level.

Regards,
Morgan

In this case it is single. But i test to copy the code of the Mark as live action of the document you just shared with me and the smart action does not appear either. It is also check the make smart action visible.

So a single smart action is only available for one record. So it’s only display if you select a record or you are on the details view of a record.

You need to restart your agent once you’ve made your change on the code. I just tested on my side it work perfectly.

If you still encounter an issue please follow the template bellow.

This is a template you can use to report issues. You can also drag images, videos and include Preformatted text

Expected behavior

Please describe here the behavior you are expecting.

Actual behavior

What is the current behavior?

Failure Logs

Please include any relevant log snippets, if necessary.

Context

Please provide any relevant information about your setup.

  • Package Version:
  • Express Version:
  • Sequelize Version:
  • Database Dialect:
  • Database Version:
  • Project Name:

Kind regards,
Morgan

1 Like