Symfony2 forms - expanded multiple choice crashes

2019-09-15 05:32发布

I have a form with field defined with this code:

$builder->add('folders', 'choice', array(
        'multiple' => true,
        'expanded' => true,
        'choices' => $this->folderManager->getMailboxes(true),
        'required' => false,
        'label' => 'Folders:'
    ));

which is rendered by:

{{ form_widget(form.folders) }}

after submiting form following exception raises:

Expected argument of type "object or array", "boolean" given

Whats wrong? Everything else works ok. No matter if i check any checkbox on list or not, still same error appears.

Code fails at bindREquest line in handler:

public function process()
{
    $search = new MbmMailSearch();
    $search->flag_answered = "bz";
    $search->flag_deleted = "bz";
    $search->flag_flag = "bz";
    $search->flag_seen = "bz";
    $search->date_type = "on";

    $this->form->setData($search);

    if ('POST' == $this->request->getMethod()) {
        $this->form->bindRequest($this->request);
        if ( $this->form->isValid() ) {

            return true;
        }
    }

    return false;
}

Ive just started working on that form, so thats why there is no data handling code.

edit: full stacktrace http://pastebin.com/gK6HVdAV

0条回答
登录 后发表回答