We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Conditional Tags

How Do I?

avori's avatar
avori
60 posts
one year ago
avori's avatar avori

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

       
Tom Jaeger's avatar
Tom Jaeger
431 posts
one year ago
Tom Jaeger's avatar Tom Jaeger

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

       
avori's avatar
avori
60 posts
one year ago
avori's avatar avori

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

       
avori's avatar
avori
60 posts
one year ago
avori's avatar avori

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}
       
troylewis's avatar
troylewis
5 posts
one year ago
troylewis's avatar troylewis

Thanks for your answer. This also helps to solve my problem.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.