We have a table field that has the default value of 1 row when a new entry is published.

Unfortunately, we have

{% if entry.tableField | length %} display markup and field content... {% endif %}

and this will always be true of each entry because of the Craft default.

Obviously, we can remove the default row in the future but wondered if there was a way to extend that condition to say, for example

{% if (entry.tableField | length) and (entry.tableField.row | length) %}

  • What is entry.tableField.row meant to say? You want to check if the table field has at least one row and...?
    – Brad Bell
    Commented Sep 30, 2015 at 21:37
  • and has content within one of the row cells Commented Oct 1, 2015 at 9:53

3 Answers 3


Something like this should do what you're looking for and will work for any number of rows:

{% set reallyEmpty = true %}

{% if entry.tableField | length %}
    {# Since you've got a default row set, we're guaranteed that [0] will be set #}
    {% for column in entry.tableField[0] %}
        {% if column|length %}
            {% set reallyEmpty = false %}
        {% endif %}
    {% endfor %}
{% endif %}

{% if reallyEmpty %}
    It's really empty.
{% else %}
    It's not empty.
{% endif %}

You can do something like this:

{% if entry.tableField|length and (
      entry.tableField[0].columnHandleOne or
      entry.tableField[0].columnHandleTwo or
   ) %}

If there’s only one column that you really care about being filled, you can simplify that to:

{% if entry.tableField|length and entry.tableField[0].columnHandle %}

For anyone googling this issue, like I did, you can also just update the Default Values in the Table fieldtype and remove the empty row that comes with that fieldtype 👍

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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