Forum

Thread tagged as: Question

Change Region Fields in the Back End based on Checkbox

Hi guys,

I'm looking for a way to alter which fields are shown in the Perch admin panel for a region, dependent on the value of a checkbox in that same region.

Here's my code so far:


<perch:content type="select" label="Display As: " id="disp-as" options="Peekthrough|pkthru,Gallery|glry" /> <perch:if id="disp-as" value="pkthru"> <perch:content type="image" label="Top Image" id="proj-pkthru-top" help="2565px x 1315px" /> <perch:content type="image" label="Bottom Image" id="proj-pkthru-bot" help="2565px x 1315px" /> </perch:if> <perch:if id="disp-as" value="glry"> <perch:before> <div class="flexslider"> <ul class="slides"> </perch:before> <li class="<perch:content id="perch_item_index" type="hidden" />"> <img class="full-screen-gallery" src="<perch:content type="image" label="Slider Image" id="slider-image" help="2565px x 1315px" />" alt="<perch:content type="text" id="img-alt" label="Image ALT" />" /> </li> <perch:after> </ul> </div> </perch:after> </perch:if>

I could have sworn I've done this before, but I couldn't find anywhere that I had done it successfully, or any other posts in the forums.

Any ideas? Thanks!

Harry Ray

Harry Ray 0 points

  • 4 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

No that hasn't ever been possible.

Hi Rachel,

Thanks - would it be possible for me to jump into the code for the back end and put some JQuery in place to accommodate this?

What repercussions would that have when it comes time to update the CMS?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

You can add your own JavaScript in a way that is not problematic in terms of updating.

https://docs.grabaperch.com/api/custom-ui/

Note that:

  1. We can't support these customisations so if you are having problems make sure that your problem exists without your custom JavaScript.
  2. Perch 3 has a changed UI, so it is likely that you'll need to update your js to update to Perch 3 when it is released.