I have an optional matrix field for a page banner in one of my channels. If someone publishes a new channel entry or edits one where the banner matrix field has never been touched, then the conditional {if banner_matrix_field}banner matrix field has content{/if}
validates as true, even though it's empty.
For example, if I publish a new page, and leave the banner matrix field empty, then the class graphic
will still display in my template:
{exp:channel:entries
channel='test'
}
<header class="banner clearfix{if banner_matrix_field} graphic{/if}">
{!-- Banner Content --}
</header><!--/.banner-->
{/exp:channel:entries}
If I add a row to the matrix field then delete it, then the field correctly validates as empty.
UPDATE: The add/delete row workaround actually only works every time you edit the entry. So if I edit the entry once, add/delete a matrix row, save, then come back and edit the same entry again and save without adding/deleting the matrix row, the conditional validates as true again.
It doesn't seem to matter what kind of fields are inside the matrix cells, I've tried it with Assets, File, and the default plain text cells with the same result.
- EE 2.6.1
- Matrix 2.5.5