<p>You can get a dropdown field's selected value by using <code>entry.fieldhandle.value</code>. So <code>if entry.fieldhandle.value|length</code> should do the trick. I think you can even omit the <code>length</code> filter in this case, as if you do it with the plain text field. Both an empty string and the length of an empty string resolve to <code>false</code>.</p>

CC BY-SA 3.0
2016-12-30T14:36:12.627Z
2016-12-30T14:36:12.627Z
Johannes
<p>In a Matrix field i want to check if block.logolink (simple text) <strong>OR</strong> block.logolinkDropdown (dropdown with empty field) are empty or not:</p>

<pre><code>{% if block.logolink or block.logolinkDropdown %}
</code></pre>

<p>If i check them with {{ block.fieldHandle }} they're empty. But still it passes the condition.</p>

<p>Where's my mistake in this statement?</p>

<pre><code>{% for block in entry.logomatrix %}
{% switch block.type %}

{% case "logo" %}
{% if block.logobild %}
    {% for logo in block.logobild %}
    {% if block.logolink or block.logolinkDropdown %}
        {% if block.internerLink %}
            &lt;a href={{ block.logolink }}{{ block.logolinkDropdown }}&gt;
        {% else %}
            &lt;a href={{ block.logolink }}{{ block.logolinkDropdown }} TARGET="_blank"&gt;
        {% endif %}
    {% else %}
        &lt;a href="{{ logo.getUrl('logogross')}}" data-lightbox="image" data-title="{{ block.logobeschreibung }}"&gt;&lt;/a&gt;
    {% endif %}

    {% endfor %}
{% endif %}

{% case "textbutton" %}     
...

{% endswitch %} 
{% endfor %}
</code></pre>

CC BY-SA 3.0
2016-12-30T12:04:31.627Z
Did you try Twig's length filter?
Johannes
CC BY-SA 3.0
2016-12-30T12:37:27.447Z
Yes, i tried the length filter first. It ouputs a 0 for the "block.logolink" and a 1 for the "block.logolinkDropdown", altough a empty field is chosen in the  dropdown.
TomS
CC BY-SA 3.0
2016-12-30T12:42:55.027Z
And how about block.logolinkDropdown.value|length?
Johannes
CC BY-SA 3.0
2016-12-30T14:29:41.977Z
That's the solution! It explains also some other questions i had. Thank you very much rostockahoi.
TomS
<matrix>
Checking if Matrix fields are empty or not?
# Checking if Matrix fields are empty or not?

(Asked by: username_0 on 2016-12-30)

In a Matrix field i want to check if block.logolink (simple text) OR block.logolinkDropdown (dropdown with empty field) are empty or not:
{% if block.logolink or block.logolinkDropdown %}

If i check them with {{ block.fieldHandle }} they're empty. But still it passes the condition.
Where's my mistake in this statement?
{% for block in entry.logomatrix %}
{% switch block.type %}

{% case "logo" %}
{% if block.logobild %}
    {% for logo in block.logobild %}
    {% if block.logolink or block.logolinkDropdown %}
        {% if block.internerLink %}
            
        {% else %}
            
        {% endif %}
    {% else %}
        
    {% endif %}

    {% endfor %}
{% endif %}

{% case "textbutton" %}     
...

{% endswitch %} 
{% endfor %}

**Tags:** matrix
> **Comments:**
> **username_1**: Did you try Twig's length filter?  
> **username_0**: Yes, i tried the length filter first. It ouputs a 0 for the "block.logolink" and a 1 for the "block.logolinkDropdown", altough a empty field is chosen in the  dropdown.  
> **username_1**: And how about block.logolinkDropdown.value|length?  
> **username_0**: That's the solution! It explains also some other questions i had. Thank you very much rostockahoi.  

---

## 1 answers

### Answer by username_1 on 2016-12-30. Score: 4 | Accepted answer

You can get a dropdown field's selected value by using `entry.fieldhandle.value`. So `if entry.fieldhandle.value|length` should do the trick. I think you can even omit the `length` filter in this case, as if you do it with the plain text field. Both an empty string and the length of an empty string resolve to `false`.


---

