Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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



20.4k

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



31.3k

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 ?



20.4k

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



31.3k
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'))); ?>