Cphalcon: isset(defined in Volt) return false on ORM attribute in Volt

Created on 15 Apr 2017  路  3Comments  路  Source: phalcon/cphalcon

Code in Controller

//...
public  function editAction(){
    //...
    $this->view->field = Fields::findFirst(5);
}
//...

Code in View

<?php var_dump(isset($field->name));?>Output false
<?php var_dump($field->name)?> Can be output value correct

Details

  • Phalcon version:3.1.1
  • PHP Version: 5.6.4 x86 vc11 Thread safe
  • Operating System: Windows 10
  • Installation type: Download dll from github release
  • Zephir version (if any): Version 0.9.6a-dev-3a72ba9bb5 (in phpinfo page)
  • Server: Apache
  • Other related info (Database, table schema):
not a bug

All 3 comments

Check that value of the $field->name is not Null. Isset will return false if variable is null.
For objects I suggest to use property_exists instead of isset.
Me myself prefer to use template engine instead of using php code in view files.

The problem is that $field->name is not null but a string form a ORM object ,isset return false,Is there a shortcut for property_exists method in volt?

I think there is no volt function for property_exist. You need to add custom function to volt compiler.
See https://docs.phalconphp.com/en/3.0.0/reference/volt.html#extending-volt

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TimurFlush picture TimurFlush  路  3Comments

mynameisbogdan picture mynameisbogdan  路  3Comments

hesalx picture hesalx  路  4Comments

linxlad picture linxlad  路  3Comments

ruudboon picture ruudboon  路  3Comments