Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Form element multiple select with setDefault

Hello,

reffering to the post of Calin Rada https://forum.phalconphp.com/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



643

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