We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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.

Phalcon\Forms\Element\Select mongodb

namespace app\forms;

use Phalcon\Forms\Form,

class RegionForm extends Form
    public function initialize()
        $country = new Select('country', \countries::find(), array(
            'using' => array('id_num','name')

<? $this->forms->set('region', new app\forms\RegionForm()); ?>
<?= $this->forms->get('region')->render('country'); ?>


PHP Catchable fatal error:  Object of class countries could not be converted to string in ...

Using mongodb. What I'm doing wrong??

edited Aug '14

I've had the same problem. It seems that documents can't be used with select. You have to modify the data from mongodb before. See below what you can do :

use Models\Profiles;

class SignUpForm extends Form
    public function initialize()
        //User profile
        $profiles = Profiles::find(array(array(
            'active' => true,
            'visible' => true),
            'fields' => array(
        $profile = new Select('profile', Profiles::returnArrayForSelect($profiles), array(
            'useEmpty' => true,
            'emptyText' => 'You are ...',
            'emptyValue' => '',
            'class' => 'form-control index-form'
use Phalcon\Mvc\Collection;

class Profiles extends Collection

    public $_id;
    public $active;
    public $name;
    public $visible;

    public static function returnArrayForSelect($obj)
        $array = array();
        foreach ($obj as $v) {
            $array[(string) $v['_id']] = $v['name'];
        return $array;


It's now really clean but it works!

Hi Everyone !

i have same question with different type. how to use with check boxes ? my code below

$postcategory = new Check('postcategory', \postcategory::find(), array( 'using' => array('id','name'), array( 'value' => $name, 'class' => 'checkbox'.$id ) )); $this->add($postcategory);