0

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?

Thanks!

2

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.

e.g.

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'

Good luck.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.