3

in order for my client to have the choice of selecting options or not, I entered an empty (blank) option in a dropdown field.

In the frontend, I use this code:

{% if entry.dropdownFieldHandle|length %}
<dt>Title</dt>
<dd>{{ entry.dropdownFieldHandle }}</dd>
{% endif %}

The problem is even if the client chooses the blank option, it still makes the code appear.

Where am I wrong?

4

If the client selects an empty value you probably will get an empty value back.

Try this:

{# Make sure we have a value #}
{% if entry.dropdownFieldHandle != "" %}
    <dt>Title</dt>
    <dd>{{ entry.dropdownFieldHandle }}</dd>
{% endif %}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.