When form is submitted and after refresh shown again, Request is binded to form and show selected values. I want to hydrate form with data from external array (session in my case) if the form was not submited before. Form is array type, not connected to any entity, as it works as db filter.
I have choice form field expanded, multiple (checkbox) configured as below:
$categoryForm = array();
$form = $this->createFormBuilder( $categoryForm )
->add( 'id', 'choice', array( 'choices' => $arrayOfChoices,
'multiple' => true,
'expanded' => true ) )
->getForm();
if ( $request->getMethod() == 'POST' ) {
$form->bindRequest( $request );
}
it is not easy case but after hours of thinking I managed to do it. Below I show mine code working great to move data from session to form and vice versa