selectStatic add standard option

Hi Community!

I have ```php {{ selectStatic(["g", genres, "using":["id", "name"], "class": "form-control"]) }} ``` The genres is filled by ```php $this->view->genres = Genres::find(); ``` Here the genres are all filled by entries from the database. But I also want the default "Not chosen" with the value "-1". Is this possible with volt syntax? If it's not not I can add the default entry to the database. Which I want to avoid


I think you want just select() and not selectStatic(). You should be able to add something like:

{{ select(["g", genres, "using":["id", "name"], "class": "form-control", 'useEmpty': true, 'emptyText': 'Not chosen', 'emptyValue': '-1']) }}


Hey! Thanks for your answer but I get an error. Which phalcon-version are you using?

Invalid arguments supplied for memnstr()

Invalid data provided to SELECT helper

Not totally sure what the issue might be. What does the compiled volt template look like from app/cache/volt ? At some point, it might be more advisable to just create a form class and then use {{ form.render('g') }} that's in the sample app to render it out.


Hey Mark,

sorry for answering so late:(

Here the part from the compiled volt template:

<?php echo $this->tag->select(array(array('g', $genres, 'using' => array('id', 'name'), 'class' => 'form-control', 'useEmpty' => true, 'emptyText' => 'Not chosen', 'emptyValue' => '-1'))); ?>

I'll try your advice to create a form class.