Forum
Perch content type = Select
I am wondering, is this element type supposed to change the regions in a Perch data entry page, e.g. when a selection is made?
I am wondering, is this element type supposed to change the regions in a Perch data entry page, e.g. when a selection is made?
No, it's for selecting one of the listed options to output to the page.
https://docs.grabaperch.com/docs/templates/attributes/type/select/
Thanks for the reply.
So is there any way to achieve what I am asking?
What are you trying to achieve?
When a selection from a list is made, if there is any further regions or if regions change the data entry page changes accordingly.
Do you mean dynamic editor forms - where certain fields are hidden/shown based on the editors selections?
Perch doesn't do that (I don't think).
But you can choose to show/hide data from the HTML output based on selections using conditionals. So whilst the editor sees all the fields, the visitor only sees what you want them to.
Here is an example of the code I am using:
<perch:content id="prerequisites" type="select" options="a, b, c, d, e, f, g, h" suppress="true" allowempty="true" />
<perch:if id="prerequisites" value="a"> <span></span> </perch:if>
<perch:if id="prerequisites" value="b"> <span></span> </perch:if>
<perch:if id="prerequisites" value="c"> <span></span> </perch:if>
<perch:if id="prerequisites" value="d"> <span></span> </perch:if>
<perch:if id="prerequisites" value="e"> <span></span> </perch:if>
<perch:if id="prerequisites" value="f"> <span></span> </perch:if>
<perch:if id="prerequisites" value="g"> <span></span> </perch:if>
<perch:if id="prerequisites" value="h"> <span></span> </perch:if>
<ul> <perch:repeater id="units" label="Units"> <li><perch:content id="unit" type="text" label="Unit" required="false" title="true" /> ‑ <perch:content id="competency" type="text" label="Competency" required="true" title="true" /></li> </perch:repeater> </ul>
I would like the unordered list to only display when specific selections are made, e.g. g or h is this possible?
Yes. Put the ul inside a perch:if and test for value.
That works, thank you very much but does this also allow for example, comma separated values?
Thanks again for writing.
I'm not completely sure what your asking, but I will attempt to answer...
Anything you place inside the perch:if will only be rendered to the output if perch:if evaluates 'true'... You can place any html template code within this perch:if and it will be output when true.
If this didn't answer your question, please provide a snippet of code showing what you expect so we can examine and respond.
Thanks, Robert Ketter
Hi Robert,
It is working but in effect there are always going to superfluous fields and besides that, I've had to make additional perch:if statements . In other words, as far as the CMS is concerned, the code will always be generated whether content is generated or not.
The dynamic forms you were talking about are what Perch really needs.
Cheers
If you have a full use case, including a code example then post it as a Suggestion. Regular Perchers know that our features are planned based on customer suggestions, but we need to be able to create general uses for them that would benefit many people, not just one customer.
Hi Rachael,
All I can say at this stage from my experience, if Dynamic Forms would not be of benefit to many people then I guess most users are happy writing redundant code.
The fact is DOM methods exist for this purpose, if the development community cannot take advantage of something in order to improve the interactions between content editors and the content management system, then one must question how deep is their commitment.