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

Customize Select Volt

I have

{{ select('category', category, 'using': ['id_category', 'name_category'],
                    'useEmpty': true, 'emptyText': 'Escolha a categoria', 'emptyValue': '@')
            }}

This shows

<select id="category" name="category">
    <option value="@">Escolha a categoria</option>
    <option value="1">Antivírus</option>
    <option value="2">Escritório</option>
</select>

He puts the category id in the option value, ok, but a need to do something like this

<option value="cat-1">Antivírus</option>
<option value="cat-2">Escritório</option>
...

How i do to customize the option value using the volt sintax?

edited Oct '15

Why dont you prepare/generate category in your model or controller and pass it to select. Something like:

$category = array();
foreach ($categoryResults as $item) {
    $category['cat-' . $item->id] = $item->title;
}
$this->view->category = $category;

And in volt:

{{ select('category', category }}

This way you will keep your template cleaner and with less logic.