当前位置: 首页>>代码示例>>PHP>>正文


PHP FormInterface::setInputFilter方法代码示例

本文整理汇总了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;
 }
开发者ID:sitrunlab,项目名称:learnzf2,代码行数:21,代码来源:IndexController.php

示例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);
 }
开发者ID:zhangyuxiao,项目名称:qoros,代码行数:40,代码来源:Factory.php

示例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');
 }
开发者ID:samsonasik,项目名称:unnamed,代码行数:17,代码来源:AdminMenuController.php

示例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);
 }
开发者ID:samsonasik,项目名称:unnamed,代码行数:13,代码来源:ContentController.php


注:本文中的Zend\Form\FormInterface::setInputFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。