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

Pb with {{ select(...) }}

Hi forum,

{{ select('country_id', country, 'using': ['country_id', 'country']) }}

Result:

<?php echo $this->tag->select(array('country_id', $country, 'using' => array('country_id', 'country'))); ?>

so compilation produce $country while Country::find() is expected



33.8k

If country isn't a previous setted var, I think you need to use Country::find



43.9k

yep, in controller I've put $this->view->country = Country::find(); to solve my pb, but the volt compilation of:

{{ select('country_id', country, 'using': ['country_id', 'country']) }}

should output:

<?php echo $this->tag->select(array('country_id', Country::find(), 'using' => array('country_id', 'country'))); ?>

should I post an issue on github ?



33.8k

Nope, you must use $this->view->setVar("country", Country::find())



43.9k
Accepted
answer

As a workaround, this is a working solution

// my controller action:
$this->view->country = Country::find(); 
// my  Volt view
{{ select('country_id', country, 'using': ['country_id', 'country']) }}
// code generated by Volt compiler
<?php echo $this->tag->select(array('country_id', $country, 'using' => array('country_id', 'country'))); ?>