This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello
I am using variables in my static page layout.
Is it possible to make these variables invisible in the CMS pages, unless the switch is set to true?
Right now, even if the switch is false, the client can still see the fields related to the switch, but the data will only show in the frontend if the switch is true.
Example: I have the following set of variables declared in my layout:
<!-- HERO IMAGE -->
{variable name="hero_enabled" label="Display?" type="switch" tab="Hero"}{/variable}
{variable name="hero_image" label="Hero image" type="mediafinder" mode="image" tab="Hero"}{/variable}
{variable name="hero_image_alt" label="Description of the image for SEO" type="text" tab="Hero"}{/variable}
So, what I would like to do is that if
hero_enabled (type switch) == false,
do not show hero_image & hero_image_alt in the backend pages tab.
Hiding the unnecessary fields in the backend would prevent a lot of confusing from the client. Is this possible with OctoberCMS? I have been googling for a long time but i can't find the answer.
Thank you for your time.
Last updated
I'd also like to know an answer to this, is it even possible and if yes, how can we achieve this?
I have a similar issue like NPXL: I'd like to use a Select input, and based on what's selected, show other fields.
I imagine it could be achievable like this:
{variable type="dropdown" name="input_group" label="Select an input group" options="inputgroup1:Inputgroup 1| inputgroup2:Inputgroup 2"}Input groups{/variable}
{% if input_group == 'inputgroup1' %}
{variable type="text" name="inputgroup1_title" label="Inputgroup 1 title"}{/variable}
{% endif %}
So the code above would result in a dropdown, and if Inputgroup 1 is selected, show the text field too
Is it possible somehow?
Last updated
What you're looking for is called trigger events: https://octobercms.com/docs/backend/forms#field-trigger-events.
trigger="action:show|field:viewBag[input_group]|condition:value[inputgroup1]"
Last updated
1-4 of 4