twigezplatform

How to get value of option from select


I contributed in back-office a select attribute with two options but when I'm doing

{{ ez_field_value(content, 'value') }} 

I get 0 or 1 according to I contributed on back-office.
How to get value of this select attribute ?


Solution

  • I don't think there's a readily available way to get the clean value of the option from Twig.

    What you can do though is use {{ ez_render_field(content, 'my_field') }} which will render the option name in a div element, but with added ezselection-field CSS class attached to it, like so:

    <div class="ezselection-field">My option</div>