public function loginAction() { $form = new UserForm(); $form->get('submit')->setValue('Sign in'); return new Viewmodel(array('form' => $form)); }
public function registerAction() { $form = new UserForm(); $request = $this->getRequest(); if ($request->isPost()) { $user = new User(); // echo $_GET['user']; // Debug::dump($request->getPost()); $form->setInputFilter($user->getInputFilter()); //就算没有输入id也可以通过检验。 $form->bind($user); $form->setData($request->getPost()); if ($form->isValid()) { // $user->setId(9); // Debug::dump($user); $this->getservice()->save($user); $this->getservice()->auth($user); // Debug::dump($form->getData());//经过bind,是一个$user对象,必须要实现exchangeArray ,get和set不必要 //Debug::dump($user);//同上 // Redirect to list of albums如果想要dump就不要转业 return $this->redirect()->toRoute('add'); } else { $messages = $form->getMessages(); // Debug::dump($messages); } } //layout()用法 // $v1=new ViewModel(array( // 'identity'=>'wyj' // )); // //网页顶部显示登陆信息一般过程 // $v1->setTemplate('blog/user/userPanel'); // $layout=$this->layout(); // $layout->addChild($v1,'userPanel'); $v = new ViewModel(array('userform' => $form)); return $v; }