本文整理汇总了PHP中Zend\Form\FormInterface::setMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::setMessages方法的具体用法?PHP FormInterface::setMessages怎么用?PHP FormInterface::setMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::setMessages方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setLoginForm
public function setLoginForm(FormInterface $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;
}
示例2: handleGetRequest
/**
* @param FormInterface $form
* @return bool|array
*/
protected function handleGetRequest(FormInterface $form)
{
$container = $this->getSessionContainer();
if (null === $container->post) {
// No previous post, bail early
unset($container->files);
return false;
}
// Collect data from session
$post = $container->post;
$errors = $container->errors;
$isValid = $container->isValid;
unset($container->post);
unset($container->errors);
unset($container->isValid);
// Fill form with the data first, collections may alter the form/filter structure
$form->setData($post);
// Remove File Input validators and filters on previously uploaded files
// in case $form->isValid() or $form->bindValues() is run
$inputFilter = $form->getInputFilter();
$this->traverseInputs($inputFilter, $post, function ($input, $value) {
if ($input instanceof FileInput) {
$input->setAutoPrependUploadValidator(false)->setValidatorChain(new ValidatorChain())->setFilterChain(new FilterChain());
}
return $value;
});
// set previous state
$form->isValid();
// re-validate to bind values
if (null !== $errors) {
$form->setMessages($errors);
// overwrite messages
}
$this->setProtectedFormProperty($form, 'isValid', $isValid);
// force previous state
// Clear previous files from session data if form was valid
if ($isValid) {
unset($container->files);
}
return $post;
}