We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

select_static problem with Volt

Hi there,

I'm trying to use select_static without success.

If I do this in the volt template, it works

echo $this->tag->selectStatic(array("status", array("A" => "Active","I" => "Inactive")));

I'm assuming the following is the correct syntax for the Volt version of the above

{{ select_static(array("status", array("A" => "Active","I" => "Inactive"))) }}

However, in this case, I get the following error

Syntax error, unexpected token ASSIGN in /Applications/MAMP/htdocs/escglam/public/../app/views/booking/index.volt on line 10

I've tried to find some examples of Volt select_static but there doesn't seem to be anything. Any ideas what I'm doing wrong here?


edited May '14

The syntax for arrays in Volt is different from the PHP syntax.

This should give you what you are looking for:

{{ select_static('status', [ 'A' : 'Active', 'I' : 'Inactive']) }}

edited Apr '14

Thank you @nethox - that did the trick :)

Is that array syntax documented anywhere? No worries, I can see the syntax in the documentation - I just hadn't noticed it before you pointed it out.


edited Apr '14

There's a bit of documentation missing here and there, I did a bit of trial and error on my side..

What I do is I look at the cache files that are generated in the /app/cache/ folder and it shows you the pure PHP output that is generated by Volt and you can work from there.

EDIT: I also use the .pdf version of the docs to CTRL+F search specific keywords, it can sometimes accelerate process of finding information within the Phalcon docs.. https://media.readthedocs.org/pdf/phalcon-php-framework-documentation/latest/phalcon-php-framework-documentation.pdf