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

Input array with <input name=list[]>

Hi all,

Just struggling with the forms in Phalcon.

I need to create a list of options: <input type="checkbox" name="list[]" value="option1"> <input type="checkbox" name="list[]" value="option2"> <input type="checkbox" name="list[]" value="option2">

<?php foreach ($list as $option) { $this->add(new Check('list[]', array('value' => 1))); } ?>

Then, I wanted to overload the bind method from form to join selected checkboxes into single variable

<?php public function bind(array $data, $entity, $whitelist = null) { $entity->list = implode(',', $data['list']); return parent::bind($data, $entity, $whitelist); } ?>

What is the suggested approach to achieve this with phalcon forms and models?

Are array elements supported at all within the forms?

Basically, I need to serialize these inputs before saving them in database and unserialize before displaying the form,

Could someone point me to the right direction please?

EDIT: Created bug report at: https://github.com/phalcon/cphalcon/issues/1537