Select multiple default values from controller, how to?

I'm trying to set default values of a multiple select field from the controller but it's not working. I'm using "$this->tag->select" in the view with the name "select[]".

From the controller, I'm trying to use "$this->tag->setDefault('select', $defaultvaluesarray);" but it's not working because setDefault doesn't accept non scalar values.

How can I make it work?



18.6k

$defaultvaluesarray has to be an array with the values of the OPTIONs ([value1, value2, ...]).



5.9k

I know this is old, but for future reference (this is phalcon 2.0.9):

$form = new EntityForm($entity, ['edit' => true]);

$form->get('yourElementName[]')->setDefault($yourArrayOfValues);