ExpressionEngine 7.5 has been Released! Learn More!
Hi,
I’m bit confused about using conditional tags in my templates. The documentation isn’t clear on this. In my channel form I have a dropdown select for company type, and based on the selection, I have conditional checkbox input to select the services for that particular company type.
Here is what I don’t understand how i would use the conditional tags in my template to output the services.
How do I tell ee which checkbox field to output? What I mean what is the syntax to use in the conditional tag for my fields.
{if my_custom_field} Output the selected items {/if}
And how do I tell ee to only output the field if it has something selected?
What I mean, is if the company type A is selected from the dropdown, it only gives me the option to select checkboxes for the conditional services field corresponding to that company type. The rest of the services checkbox inputs are hidden. How do I add the conditional tag to the template that will only output that field if it has something selected in it.
Regards, Viktor
Howdy Viktor,
Thanks for posting this.
Just to confirm. Your looking to use conditional fields in a channel form currently?
If so, that’s not currently supported natively. However that sounds like an awesome idea! Any chance you would be willing to add that as a Feature Request?
Thanks,
-Tom Jaeger
Hi Tom,
At this point, no. I just need to add it to my entry.html template. However, I did want to add that to a future version of the website to allow the members to be able to add their companies themselves, in which case that would be needed in channel forms as well.
Sure, I don’t mind adding a feature request.
-Viktor
BTW. I should mention that I have figured out what I needed with this one, in case someone will need it.
The documentation does not mention that you can use the channel fields that you set up as a condition variable. There is a list of short and global variables, but no mention of channel fields and that’s what had me confused.
Here is what I ended up doing and it works perfectly.
{if insurance_services}
{insurance_services}
<div class="offer-item">
<i class="las la-check-circle offer-icon"></i>
<h3 class="offer-text">{item:label}</h3>
</div>
{/insurance_services}
{/if}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.