Symfony2 form with field not in entity

authentication, entity, forms, php, symfony

Solution

In reading the symfony 2 doc : http://symfony.com/doc/current/book/forms.html

In your field (in formType), you should add the option 'mapped' to 'false'

$builder->add('task')
    ->add('dueDate', null, array('mapped' => false))
    ->add('save', 'submit');

Problem

this may be very easy but i'm new to symfony2, so i thought asking first. i'm creating a login form in a controller: ``` public function showAction() { $admin = new Administrator(); $form = $this->createFormBuilder($admin)->setAction($this->generateUrl('admin_login_process')) ->setMethod('POST') ->add('username', 'text') ->add('password', 'password') ->add('remember', 'checkbox') ->add('login', 'submit') ->getForm(); return $this->render('EraAdminBundle:Login:login.html.php', array('form'=>$form->createView())); } ``` the username and password fields are part of the administrator entity, but the remember checkbox is not of course. how do i submit it together with the form? cause if i let it as it is i get this error: ``` Neither the property "remember" nor one of the methods "getRemember()", "isRemember()", "hasRemember()", "__get()" or "__call()" exist and have public access in class "Era\RestoranteBundle\Entity\Administrator". ```

Original source