I'm trying to put two hidden fields in a form for a particular user. I have this code:
<div id="mio_miobundle_empleadotype">
{{ form_row(edit_form.dni) }}
{{ form_row(edit_form.nombre) }}
{{ form_row(edit_form.username) }}
{{ form_row(edit_form.apellido1) }}
{{ form_row(edit_form.apellido2) }}
{{ form_row(edit_form.localidad) }}
{{ form_row(edit_form.provincia) }}
{{ form_row(edit_form.telefono) }}
{{ form_row(edit_form.movil) }}
{{ form_row(edit_form.email) }}
{{ form_row(edit_form.direccion) }}
{% if is_granted('ROLE_A') %}
{{ form_row(edit_form.activo) }}
{{ form_row(edit_form.role) }}
{%endif%}
{{ form_row(edit_form.password) }}
and:
$builder
->add('dni','text',array('label' => 'Dni'))
->add('nombre','text',array('label' => 'Nombre'))
->add('username','text',array('label' => 'Usuario'))
->add('apellido1','text',array('label' => 'Apellido1'))
->add('apellido2','text',array('label' => 'Apellido2'))
->add('email','email',array('label' => 'Email'))
->add('localidad','text',array('label' => 'Localidad'))
->add('provincia','text',array('label' => 'Provincia'))
->add('telefono','text',array('label' => 'Teléfono'))
->add('movil','text',array('label' => 'Móvil'))
->add('direccion','text',array('label' => 'Dirección'))
->add('activo')
->add('role')
->add('password', 'repeated', array('first_name' => 'Nueva contraseña','second_name' => 'Repite contraseña','type' => 'password' ,'invalid_message'=> 'Las contraseñas deben ser iguales.'))
;
}
but I get this error:
Catchable Fatal Error: Argument 1 passed to
mio\mioBundle\Entity\Empleado::setRole()
must be an instance ofmio\mioBundle\Entity\Role
,null
given, called in /var/www/Symfony/vendor/symfony/src/Symfony/Component/Form/Util/PropertyPath.php on line 347 and defined in /var/www/Symfony/src/mio/mioBundle/Entity/Empleado.php line 289
I say that because I have to fill in the state are any help?