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', $default_values_array);" but it's not working because setDefault doesn't accept non scalar values.

How can I make it work?



20.4k

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



6.5k

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);