Is there a way to show or hide a widget based on the value of another widget within the same collection?

Hi there,

I’m currently setting up collections for my already existing Hugo site. I’m hoping to successfully migrate the CMS from Forestry to Netlify CMS. Everything is nice and straightforward but there’s one thing I can’t figure out. I need a way to display certain widgets within a collection based on the value of another widget within that same collection. I.E “show this widget only if the value of widget X is set to true.”

A use-case example of this is the option to display an image grid on a certain page. I would want the widgets for choosing the images, captions, alt-text etc to only be visible if the editor has chosen to display the image grid. If the show_image_grid widget is set to false, I want to hide the dependent widgets for a more streamlined UI.

I’m using this type of functionality in several places on my site. I want to ensure that the editor won’t see or try to edit fields if they haven’t explicitly enabled those fields to be output in the template upon build.

Is this something I can achieve without creating a custom widget?

Howdy and sorry to be so slow to get back to you!

Our Support team isn’t really experts on the CMS at that level (we don’t use any feature like that and aren’t super familiar with the implementation details), but maybe @tomrutgers could guide us on whether that is possible in any way he can imagine? Or perhaps if instead we should ask you to post a feature request… He is an expert having contributed to the CMS for many years now :slight_smile:

That unfortunately isn’t possible yet, but there’s an open feature request which you can track here: dependent fields in collection · Issue #565 · netlify/netlify-cms · GitHub

2 Likes