本文整理汇总了PHP中Zend\Form\Form::setMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::setMessages方法的具体用法?PHP Form::setMessages怎么用?PHP Form::setMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Form
的用法示例。
在下文中一共展示了Form::setMessages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginAction
/**
* Login form
*/
public function loginAction()
{
if ($this->zfcUserAuthentication()->hasIdentity()) {
return $this->redirect()->toRoute($this->options->getLoginRedirectRoute());
}
$request = $this->getRequest();
$post = $request->getPost();
$form = $this->loginForm;
$fm = $this->flashMessenger()->setNamespace('zfcuser-login-form')->getMessages();
if (isset($fm[0])) {
$this->loginForm->setMessages(array('identity' => array($fm[0])));
}
if ($this->options->getUseRedirectParameterIfPresent()) {
$redirect = $request->getQuery()->get('redirect', !empty($post['redirect']) ? $post['redirect'] : false);
} else {
$redirect = false;
}
if (!$request->isPost()) {
return array('loginForm' => $form, 'redirect' => $redirect, 'enableRegistration' => $this->options->getEnableRegistration());
}
$form->setData($post);
if (!$form->isValid()) {
$this->flashMessenger()->setNamespace('zfcuser-login-form')->addMessage($this->failedLoginMessage);
return $this->redirect()->toUrl($this->url()->fromRoute(static::ROUTE_LOGIN) . ($redirect ? '?redirect=' . rawurlencode($redirect) : ''));
}
// clear adapters
$this->zfcUserAuthentication()->getAuthAdapter()->resetAdapters();
$this->zfcUserAuthentication()->getAuthService()->clearIdentity();
return $this->forward()->dispatch(static::CONTROLLER_NAME, array('action' => 'authenticate'));
}
示例2: setLoginForm
public function setLoginForm(Form $loginForm)
{
$this->loginForm = $loginForm;
$fm = $this->flashMessenger()->setNamespace('zfcuser-login-form')->getMessages();
if (isset($fm[0])) {
$this->loginForm->setMessages(array('identity' => array($fm[0])));
}
return $this;
}
示例3: setLoginForm
/**
* @param Form $loginForm
* @return $this
*/
public function setLoginForm(Form $loginForm)
{
$this->loginForm = $loginForm;
$fm = $this->flashMessenger()->getMessages();
if (isset($fm[0])) {
$this->loginForm->setMessages(['identity' => [$fm[0]]]);
}
return $this;
}