We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

ilogical check if object.attribute is empty or not

hi

how to check if object attribute is not empty?


{# never works #}
{% if not (object.attribute is empty) %}

{# never works #}
{% if ! (object.attribute is empty) %}

{# php code generated #}
<?php if (!(empty($object->attribute))) { ?>

{# ... #}

{# inverted logic #}
{# "if object.attribute IS EMPTY..." #}
{# expected: return FALSE if object.attribute have anything - is not empty #}
{# result: return TRUE if object.attribute have anything - ??? #}
{% if object.attribute is empty %}

{# php code generated #}
<?php if (empty($object->attribute)) { ?>

{# ... #}

{# never works #}
{% if object.attribute is defined %}

{# php code generated #}
<?php if (isset($object->attribute)) { ?>

{# ... #}

{# inverted logic #}
{# "if object.attribute is NOT defined..." #}
{# expected: return FALSE if object.attribute have anything - is defined #}
{# result: return TRUE if object.attribute have anything - ??? #}
{% if not (object.attribute is defined) %}

{# inverted logic #}
{% if ! (object.attribute is defined) %}

{# php code generated #}
<?php if (!(isset($object->attribute))) { ?>

it just me, or you are with the inverted logic?

what to do?

thanks

Something like {% if object.attirbute %} do something here {% else %} do something here {% endif %} like in symfony dont work ?