I have a Matrix field that includes three options. The aim is to output a <select>
element if one or more of these options is selected. (These fields are Pixel & Tonic Field Pack checkboxes.)
This syntax used to work:
{if "{gold}" OR "{silver}" OR "{wood}"}
<input type="hidden" name="on0" value="Frame Type">
<select name="os0">
{if gold}<option value="Gold">Gold Frame</option>{/if}
{if silver}<option value="Silver">Silver Frame</option>{/if}
{if wood}<option value="Rosewood">Rosewood Frame</option>{/if}
</select>
{/if}
Now that I've upgraded to EE 2.8.1 (from a much earlier version—E 2.2) the code isn't working and I'm getting the following error:
A PHP Error was encountered
Severity: User Warning
Message: Invalid EE Conditional Variable: {if ""y"}
Filename: libraries/Functions.php
Line Number: 2640
I've tried all sorts of syntax combinations, such as removing the quotes and braces etc. The only solution I could find was pretty inefficient:
{if gold}
<input type="hidden" name="on0" value="Frame Type">
<select name="os0">
{if gold}<option value="Gold">Gold Frame</option>{/if}
{if silver}<option value="Silver">Silver Frame</option>{/if}
{if wood}<option value="Rosewood">Rosewood Frame</option>{/if}
</select>
{if:elseif silver}
<input type="hidden" name="on0" value="Frame Type">
<select name="os0">
{if gold}<option value="Gold">Gold Frame</option>{/if}
{if silver}<option value="Silver">Silver Frame</option>{/if}
{if wood}<option value="Rosewood">Rosewood Frame</option>{/if}
</select>
{if:elseif wood}
<input type="hidden" name="on0" value="Frame Type">
<select name="os0">
{if gold}<option value="Gold">Gold Frame</option>{/if}
{if silver}<option value="Silver">Silver Frame</option>{/if}
{if wood}<option value="Rosewood">Rosewood Frame</option>{/if}
</select>
{if:else}
{/if}
At least it works, but it's pretty darned ugly and inefficient. I had to put that ugly if:else
at the end, too, as each of the options is optional, so to speak.
Can anyone suggest a better way to construct this?