本文整理汇总了PHP中Zend\Form\FormInterface::setInputFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::setInputFilter方法的具体用法?PHP FormInterface::setInputFilter怎么用?PHP FormInterface::setInputFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::setInputFilter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$result = ['result' => false, 'message' => ''];
$viewModel = $this->acceptableviewmodelselector($this->acceptCriteria);
$request = $this->getRequest();
if ($request->isPost()) {
$login = new LoginInputFilter();
$this->loginForm->setInputFilter($login->getInputFilter());
$this->loginForm->setData($request->getPost());
if ($this->loginForm->isValid()) {
$result = ['result' => true, 'message' => 'Ajax request success'];
} else {
$result = ['result' => false, 'message' => $this->loginForm->getMessages()];
}
}
if (!$viewModel instanceof JsonModel && $request->isXmlHttpRequest()) {
$viewModel = new JsonModel();
}
$viewModel->setVariables(['form' => $this->loginForm, 'data' => $result]);
return $viewModel;
}
示例2: prepareAndInjectInputFilter
/**
* Prepare an input filter instance and inject in the provided form
*
* If the input filter specified is a string, assumes it is a class name,
* and attempts to instantiate it. If the class does not exist, or does
* not extend InputFilterInterface, an exception is raised.
*
* Otherwise, $spec is passed on to the attached InputFilter Factory
* instance in order to create the input filter.
*
* @param string|array|Traversable $spec
* @param FormInterface $form
* @param string $method
* @return void
* @throws Exception\DomainException for unknown InputFilter class or invalid InputFilter instance
*/
protected function prepareAndInjectInputFilter($spec, FormInterface $form, $method)
{
if ($spec instanceof InputFilterInterface) {
$form->setInputFilter($spec);
return;
}
if (is_string($spec)) {
if (!class_exists($spec)) {
throw new Exception\DomainException(sprintf('%s expects string input filter names to be valid class names; received "%s"', $method, $spec));
}
$filter = new $spec();
if (!$filter instanceof InputFilterInterface) {
throw new Exception\DomainException(sprintf('%s expects a valid implementation of Zend\\InputFilter\\InputFilterInterface; received "%s"', $method, $spec));
}
$form->setInputFilter($filter);
return;
}
$factory = $this->getInputFilterFactory();
$filter = $factory->createInputFilter($spec);
if (method_exists($filter, 'setFactory')) {
$filter->setFactory($factory);
}
$form->setInputFilter($filter);
}
示例3: processFormData
/**
* @param FormInterface $form
* @param \Zend\Http\Request $request
* @param AdminMenu $adminMenu
*
* @return \Zend\Http\Response
*/
private function processFormData(FormInterface $form, \Zend\Http\Request $request, AdminMenu $adminMenu)
{
$form->setInputFilter($form->getInputFilter());
$form->setData($request->getPost());
if ($form->isValid()) {
$this->adminMenuTable->saveAdminMenu($adminMenu);
$this->setLayoutMessages('«' . $adminMenu->getCaption() . '» ' . $this->translate('SAVE_SUCCESS'), 'success');
}
return $this->redirect()->toUrl('/admin/admin-menu');
}
示例4: processFormData
/**
* @param FormInterface $form
* @param Content $content
* @param array $data
*
* @return void
*/
private function processFormData(FormInterface $form, Content $content, array $data)
{
$form->setInputFilter($form->getInputFilter());
$form->setData($data);
$this->saveFormData($form, $content);
}