这可能很简单,但我还是新手Symfony2,所以我想先问一下。我正在控制器中创建一个登录表单:
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()));
}
用户名和密码字段属于管理员实体,但是记住复选框显然不属于其中。我该如何将其与表单一起提交?因为如果我按原样提交,就会出现以下错误:
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".