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".
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');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With