Is there a way to conditionally display channel fields (not required ones at least) based on a prior selection from a dropdown field in the publish layout for any channel?
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It only takes a minute to sign up.Sign up to join this community
The way I've done this in the past is to add some custom js to the footer of the Control panel.
You shouldn't edit the core files directly but what you can do is make a Theme and then copy the core files you want to make edits to into your theme.
Don't let the word theme put you off, you dont have to recreate an entire cp layout. only make duplicates of the core files you want to make edits to and EE will fallback on the core files where your theme doesn't have the required ones.
Inside '/themes' (not 'system/ee/third-party/themes') Create a new folder with the name of your new theme.
The file I used is footer.php inside 'system/ee/views/_shared/footer.php'
copy this to your theme folder as /themes/yourThemeName/_shared/footer.php'
then inside your new footer.php file you can add some js that detects the val() of your dropdown field, then hides/shows others depending on your selection.
you may need to select fields based on their wrapping divs ID's or you can use the fields name attribute.
it's a little bit tricky but it is possible.
OH and lastly make sure to select your new CP theme in 'Admin > General Configuration > Default Control Panel Theme'