I have an entity field type in my form, but then when I try to get the values from the controller I get an error.
This is my form builder
$builder
->add('recursos', 'entity', array(
'class' => 'SIGIConvocatoriasBundle:Recurso',
'property' => 'nombre',
'multiple' => true,
'mapped' => false
))
->add('requisitos', 'entity', array(
'class' => 'SIGIConvocatoriasBundle:Requisito',
'property' => 'nombre',
'multiple' => true,
'mapped' => false
))
;
and this is my controller
$entity = new Convocatoria();
$form = $this->createForm(new ConvocatoriaType(), $entity);
$form->bind($request);
$recursos = $request->request->get('recursos');
foreach ($recursos as $recurso)
{
//Do something ...
}
But I get an error here
Invalid argument in foreach ...
Like if the $recursos
variable is empty or something, and I get a 'recursos' => null
in the symfony exception.
I'd really appreciate some help here :D