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


PHP FormInterface::isValid方法代码示例

本文整理汇总了PHP中Zend\Form\FormInterface::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::isValid方法的具体用法?PHP FormInterface::isValid怎么用?PHP FormInterface::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Form\FormInterface的用法示例。


在下文中一共展示了FormInterface::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateAction

 public function updateAction()
 {
     $request = $this->getRequest();
     $recipe = $this->readService->findById($this->params('id'));
     if (false === $this->authorizationService->isGranted('recipe.manage', $recipe)) {
         throw new UnauthorizedException('Insufficient Permissions');
     }
     $viewModel = new ViewModel();
     $viewModel->setTemplate('recipe/update');
     $viewModel->setVariables(['form' => $this->form]);
     $this->form->bind($recipe);
     if ($request->isPost()) {
         $this->form->setData($request->getPost());
         if ($this->form->isValid()) {
             try {
                 $this->writeService->save($this->form->getData());
                 $this->flashMessenger()->addSuccessMessage('Rezept erfolgreich aktualisiert');
                 $this->redirect()->toRoute('recipe/read/update', ['id' => $this->params('id')]);
             } catch (\Exception $e) {
                 var_dump($e->getMessage());
             }
         }
     }
     $this->layout('layout/backend');
     return $viewModel;
 }
开发者ID:Indigo1337,项目名称:c4d,代码行数:26,代码来源:Update.php

示例2: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     $logContent = '';
     // initialize when no submit anymore
     $data = [];
     $data['logmessage'] = $this->form->get('logmessage')->getValue();
     if ($request->isPost()) {
         $this->form->setData($request->getPost());
         if ($this->form->isValid()) {
             $data = $this->form->getData();
             $this->loggerPriority = $data['logpriority'];
             if ($data['logformat'] !== 'simple') {
                 $this->loggerConfig['writers'][0]['options']['formatter']['name'] = $data['logformat'];
                 unset($this->loggerConfig['writers'][0]['options']['formatter']['options']);
             }
         }
     }
     $logger = new Logger($this->loggerConfig);
     // save log data to buffer and make it variable
     ob_start();
     $logger->log((int) $this->loggerPriority, $data['logmessage']);
     $logContent = ob_get_clean();
     return new ViewModel(['form' => $this->form, 'logContent' => $logContent]);
 }
开发者ID:shitikovkirill,项目名称:LearnZF2,代码行数:25,代码来源:IndexController.php

示例3: manageAction

 public function manageAction()
 {
     if (false === $this->authorizationService->isGranted('user.admin')) {
         throw new UnauthorizedException('Insufficient Permissions');
     }
     $userId = $this->params('id', null);
     if (null === $userId) {
         return $this->listUsers();
     }
     $userObject = $this->userService->findById($userId);
     if (false === $userObject instanceof UserEntity) {
         return $this->listUsers();
     }
     $request = $this->getRequest();
     $viewModel = new ViewModel();
     $viewModel->setTemplate('user/update');
     $viewModel->setVariables(['form' => $this->form]);
     $this->form->bind($userObject);
     if ($request->isPost()) {
         $this->form->setData($request->getPost());
         if ($this->form->isValid()) {
             try {
                 $this->userService->save($this->form->getData());
                 $this->flashMessenger()->addSuccessMessage('User successfully updated');
                 return $this->redirect()->toRoute('zfcuser/manage');
             } catch (\Exception $e) {
                 var_dump($e->getMessage());
             }
         } else {
             var_dump($this->form->getMessages());
         }
     }
     return $viewModel;
 }
开发者ID:Indigo1337,项目名称:c4d,代码行数:34,代码来源:Manage.php

示例4: createAction

 public function createAction()
 {
     if ($this->getRequest()->isPost()) {
         $this->dashboardForm->setData($this->getRequest()->getPost());
         if ($this->dashboardForm->isValid()) {
             $data = $this->dashboardForm->getData();
             $this->dashboardTaskService->persistFromArray($data);
             return $this->redirect()->toRoute('dashboard/manage');
         }
     }
     return new ViewModel(['dashboardForm' => $this->dashboardForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:12,代码来源:Dashboard.php

示例5: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     $formMessages = [];
     $isPost = false;
     if ($request->isPost()) {
         $this->form->setData($request->getPost());
         $this->form->isValid();
         $formMessages = $this->form->getMessages();
         $isPost = true;
     }
     return new ViewModel(['form' => $this->form, 'formMessages' => $formMessages, 'isPost' => $isPost]);
 }
开发者ID:shitikovkirill,项目名称:LearnZF2,代码行数:13,代码来源:FormController.php

示例6: indexAction

 /**
  * 
  * @return ViewModel|Response
  */
 public function indexAction()
 {
     if (!is_null($this->identity())) {
         return $this->redirect()->toRoute($this->loginRedirectRoute);
     }
     if ($this->getRequest()->isPost()) {
         $this->loginForm->setData($this->getRequest()->getPost());
         if ($this->loginForm->isValid()) {
             return $this->redirect()->toRoute($this->loginRedirectRoute);
         }
     }
     return new ViewModel(array('loginForm' => $this->loginForm));
 }
开发者ID:ughly,项目名称:ugh-authentication,代码行数:17,代码来源:LoginController.php

示例7: indexAction

 public function indexAction()
 {
     $this->settingsForm->setData($this->settingsManager->getAll());
     if ($this->getRequest()->isPost()) {
         $this->settingsForm->setData($this->getRequest()->getPost());
         if ($this->settingsForm->isValid()) {
             $data = $this->settingsForm->getData();
             $this->settingsManager->set('application_title', $data['application_title']);
             $this->settingsManager->flush();
             $this->flashMessenger()->addSuccessMessage('The settings have been saved.');
             return $this->redirect()->toRoute('admin/system/settings');
         }
     }
     return new ViewModel(['settingsForm' => $this->settingsForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:15,代码来源:AdminSettings.php

示例8: updateAction

 public function updateAction()
 {
     $person = $this->contactService->findPerson($this->params('id'));
     if (!$person) {
         return $this->notFoundAction();
     }
     $this->contactForm->bind($person);
     if ($this->getRequest()->isPost()) {
         $this->contactForm->setData($this->getRequest()->getPost());
         if ($this->contactForm->isValid()) {
             $person = $this->contactService->persistContact($this->contactForm->getData());
             return $this->redirect()->toRoute('contacts/view', ['type' => ContactEntry::TYPE_PERSON, 'id' => $person->getId()->toString()]);
         }
     }
     return new ViewModel(['person' => $person, 'contactForm' => $this->contactForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:16,代码来源:Person.php

示例9: updateAction

 public function updateAction()
 {
     $company = $this->contactService->findCompany($this->params('id'));
     if (!$company) {
         return $this->notFoundAction();
     }
     $this->contactForm->bind($company);
     if ($this->getRequest()->isPost()) {
         $this->contactForm->setData($this->getRequest()->getPost());
         if ($this->contactForm->isValid()) {
             $company = $this->contactService->persistContact($this->contactForm->getData());
             return $this->redirect()->toRoute('contacts/view', ['type' => ContactEntry::TYPE_COMPANY, 'id' => $company->getId()->toString()]);
         }
     }
     return new ViewModel(['company' => $company, 'contactForm' => $this->contactForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:16,代码来源:Company.php

示例10: resetPasswordAction

 public function resetPasswordAction()
 {
     $code = $this->params('code');
     if ($code) {
         $this->resetPasswordForm->get('code')->setValue($code);
     }
     if ($this->getRequest()->isPost()) {
         $this->resetPasswordForm->setData($this->getRequest()->getPost());
         if ($this->resetPasswordForm->isValid()) {
             $data = $this->resetPasswordForm->getData();
             $this->passwordChanger->resetAccountPassword($data['code'], $data['credential']);
             return $this->redirect()->toRoute('login');
         }
     }
     return new ViewModel(['resetPasswordForm' => $this->resetPasswordForm, 'code' => $code]);
 }
开发者ID:zource,项目名称:zource,代码行数:16,代码来源:Request.php

示例11: indexAction

 /**
  * Use the form to get barcode image from selected barcode object.
  */
 public function indexAction()
 {
     $request = $this->getRequest();
     //default value without post parameter
     $barcodeOptions = ['text' => '123456789'];
     $barcode = Barcode::factory('codabar', 'image', $barcodeOptions);
     if ($request->isPost()) {
         $this->form->setData($request->getPost());
         if ($this->form->isValid()) {
             $barcodeOptions = ['text' => $this->form->getData()['barcode-object-text']];
             $barcode = Barcode::factory($this->form->getData()['barcode-object-select'], 'image', $barcodeOptions);
         }
     }
     imagegif($barcode->draw(), './data/barcode.gif');
     return new ViewModel(['form' => $this->form]);
 }
开发者ID:shitikovkirill,项目名称:LearnZF2,代码行数:19,代码来源:BarcodeController.php

示例12: changesAction

 public function changesAction()
 {
     $siteId = $this->services->getUtilityService()->getSiteId();
     $site = $this->services->getSiteService()->find($siteId);
     $fromControl = $this->dateIntervalForm->get(DateIntervalForm::FROM_DATE_NAME);
     $toControl = $this->dateIntervalForm->get(DateIntervalForm::TO_DATE_NAME);
     $lastDate = $site->getLastUpdate();
     $lastDate->setTime(23, 59, 59);
     $fromControl->setAttribute('max', $lastDate->format('Y-m-d'));
     $toControl->setAttribute('max', $lastDate->format('Y-m-d'));
     $from = clone $lastDate;
     $from->sub(new \DateInterval('P1M'));
     $to = $lastDate;
     $fromControl->setValue($from->format('Y-m-d'));
     $toControl->setValue($to->format('Y-m-d'));
     $request = $this->getRequest();
     if ($request->isPost()) {
         $this->dateIntervalForm->setData($request->getPost());
         if ($this->dateIntervalForm->isValid()) {
             $from = \DateTime::createFromFormat('Y-m-d', $fromControl->getValue());
             $to = \DateTime::createFromFormat('Y-m-d', $toControl->getValue());
         }
     }
     $from->setTime(0, 0, 0);
     $to->setTime(23, 59, 59);
     $result = array('intervalForm' => $this->dateIntervalForm, 'site' => $site, 'members' => $this->getMembersData($siteId, $from, $to), 'pages' => $this->getPagesData($siteId, $from, $to), 'revisions' => $this->getRevisionsData($siteId, $from, $to), 'votes' => $this->getVotesData($siteId, $from, $to));
     return new ViewModel($result);
 }
开发者ID:FiftyNine,项目名称:ScpperDB,代码行数:28,代码来源:ChangesController.php

示例13: indexAction

 public function indexAction()
 {
     if ($this->getRequest()->isPost()) {
         $this->installForm->setData(array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray()));
         if ($this->installForm->isValid()) {
             $data = $this->installForm->getData();
             if ($data['plugin']['error'] === 0) {
                 $this->pluginManager->installFile($data['plugin']['tmp_name']);
             } else {
                 $this->pluginManager->installExternal($data['location']);
             }
             $this->flashMessenger()->addSuccessMessage('The plugin has been installed.');
             return $this->redirect()->toRoute('admin/system/plugins');
         }
     }
     return new ViewModel(['plugins' => $this->pluginManager->getPlugins(), 'installForm' => $this->installForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:17,代码来源:AdminPlugins.php

示例14: editAction

 public function editAction()
 {
     $client = $this->clientRepository->find($this->params('clientId'));
     if ($client === null) {
         $this->getResponse()->setStatusCode(404);
         return;
     }
     $this->clientForm->bind($client);
     if ($this->getRequest()->isPost()) {
         $this->clientForm->setData($this->getRequest()->getPost());
         if ($this->clientForm->isValid()) {
             $this->clientService->persist($this->clientForm->getData());
             $this->redirect()->toRoute('clients/show', ['clientId' => $client->getId()]);
         }
     }
     return new ViewModel(['form' => $this->clientForm]);
 }
开发者ID:DavidHavl,项目名称:Ajasta,代码行数:17,代码来源:ClientController.php

示例15: editAction

 /**
  * @return \Zend\Http\Response|ViewModel
  */
 public function editAction()
 {
     $request = $this->getRequest();
     $post = $this->postService->findPost($this->params('id'));
     $this->postForm->bind($post);
     if ($request->isPost()) {
         $this->postForm->setData($request->getPost());
         if ($this->postForm->isValid()) {
             try {
                 $this->postService->savePost($this->postForm->getData());
                 return $this->redirect()->toRoute('blog');
             } catch (\Exception $e) {
             }
         }
     }
     return new ViewModel(array('form' => $this->postForm));
 }
开发者ID:asilich,项目名称:zendtest,代码行数:20,代码来源:WriteController.php


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