本文整理匯總了PHP中models\User::getMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getMessages方法的具體用法?PHP User::getMessages怎麽用?PHP User::getMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::getMessages方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: registerAction
public function registerAction()
{
$user = new User();
$success = $user->save($this->request->getPost());
if ($success) {
return $this->redirect('signin/index');
} else {
echo 'Sorry, the following problems were generated: ';
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), '<br/>';
}
}
$this->view->disable();
}
示例2: registerAction
public function registerAction()
{
$user = new User();
$data = $this->request->getPost();
$user->password = isset($data['password']) ? $data['password'] : null;
$user->retype_password = isset($data['retype_password']) ? $data['retype_password'] : null;
if ($user->save($data)) {
if ($this->getUser()->login($user->email, $user->password)) {
return $this->redirect('account/index');
} else {
return $this->redirect('signin/index');
}
} else {
echo 'Sorry, the following problems were generated: ';
foreach ($user->getMessages() as $message) {
echo $message->getMessage(), '<br/>';
}
}
$this->view->disable();
}
示例3: addAction
public function addAction()
{
$formData = [];
if ($this->request->isPost()) {
if ($this->security->checkToken()) {
$formData = $this->request->getPost();
$userModel = new User();
$userModel->name = $formData['name'];
$userModel->email = $formData['email'];
$userModel->password = $this->security->hash($formData['password']);
$userModel->gender = $formData['gender'];
$userModel->role = $formData['role'];
$userModel->status = $formData['status'];
if ($userModel->create()) {
$formData = [];
$this->flash->success('Add user successfully');
} else {
$this->flash->outputMessage('error', $userModel->getMessages());
}
}
}
$this->view->setVars(['formData' => $formData, 'roles' => User::$roles, 'status' => User::$statusName]);
$this->tag->prependTitle('Add user');
}