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

Select value for textbox

Hi guys,

I was playing around with Volt and i ran across the problem that i can't seem to set default value for select boxes. The following code is what i have now, but there's no selected value.

The value of status is in customer.status

{{ select_static('status', ['0' : 'Niet-actief', '1' : 'Actief'], 'class' : 'form-control') }}

Thanks in advance!

Hi!

For example, $status contains the data necessary to fill the SELECT tag using Phalcon\Tag::select and into controller that seems like this:

// Current status
Tag::displayTo('status', $status);
// List of all statuses
$this->view->setVar("statuses", Posts::getStatuses());

And this how we can create and fill SELECT in Volt:

{{ select("status", statuses, "using": ["id", "name"]) }}


2.4k

Hey Maxim,

Thanks for helping out, it works now! ;-)