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

Form element multiple select with setDefault

Hello,

reffering to the post of Calin Rada https://forum.phalcon.io/discussion/4209/select-multiple-setdefault

i have set up my form element in the same way. But i get a "Array to string" error by the form-render function.

Message:

Notice: Array to string conversion in C:\xampp\htdocs\phalcon\app\cache....

Whats wrong in my code? Thanks for help.

Form-Class:

$select = new Select("type[]", array(1 => 'PayPal', 2 => 'amazon', 3 => 'skrill'), array('useEmpty' => false, 'multiple' => true));
$select->setLabel('Beratertyp');
$select->setDefault(array(1,2));
$this->add($select);

Volt file:

 <div class="row">
 <div class="col-md-10">
 <div class="form-group">
 {{ form.label('type[]', ['class' : 'control-label']) }}<br>
 {{ form.render('type[]', ['class' : 'form-control']) }}
 {{ form.messages('type[]') }}
 </div>
 </div>
 </div>

Cache file:

<div class="row">
<div class="col-md-10">
<div class="form-group">
<?php echo $form->label('type[]', array('class' => 'control-label')); ?><br>
<?php echo $form->render('type[]', array('class' => 'form-control')); ?>
<?php echo $form->messages('type[]'); ?>
</div>
</div>
</div>


4.0k
Accepted
answer

Try update to latest Phalcon version 2.0.4. It was fixed #10543



1.4k

Thanks for your answer. I have to wait for the windows dll.