2

I'm having a small problem with table fields. My issue is that by default a table fields starts with one row. Even if you leave this row empty (no values at all in any column) the field will never return as empty because that row exists even though it has no value. In order to get an empty field check like this to work:

{% if entry.whiskeyTableHandle | length %}

You have to actually delete that first empty row rather than simply leave it blank.

I cannot count on my client to remember to delete the row to indicate an empty field.

Would there be any way to have the table field show in the CP publish page with no rows visible by default? That means if nothing is added to the field it will properly return as empty.

3

You could test if the first cell is empty

{% if entry.whiskeyTableHandle|length and entry.whiskeyTableHandle[0][0] %}
{% endif %}

Or you simply remove all default rows in the field’s settings.

| improve this answer | |
  • Ahhhh.....I didn't realise the row could be deleted at the default level. That's exactly what I was looking for and solved my problem. Thanks. – Benek Lisefski Oct 15 '16 at 6:17

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.