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


PHP FormInterface::getData方法代码示例

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


在下文中一共展示了FormInterface::getData方法的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()
 {
     $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

示例6: 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

示例7: 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

示例8: 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

示例9: handlePostRequest

 /**
  * @param  FormInterface $form
  * @param  string        $redirect      Route or URL string (default: current route)
  * @param  bool          $redirectToUrl Use $redirect as a URL string (default: false)
  * @return Response
  */
 protected function handlePostRequest(FormInterface $form, $redirect, $redirectToUrl)
 {
     $container = $this->getSessionContainer();
     $request = $this->getController()->getRequest();
     $postFiles = $request->getFiles()->toArray();
     $postOther = $request->getPost()->toArray();
     $post = ArrayUtils::merge($postOther, $postFiles, true);
     // Fill form with the data first, collections may alter the form/filter structure
     $form->setData($post);
     // Change required flag to false for any previously uploaded files
     $inputFilter = $form->getInputFilter();
     $previousFiles = $container->files ?: array();
     $this->traverseInputs($inputFilter, $previousFiles, function ($input, $value) {
         if ($input instanceof FileInput) {
             $input->setRequired(false);
         }
         return $value;
     });
     // Run the form validations/filters and retrieve any errors
     $isValid = $form->isValid();
     $data = $form->getData(FormInterface::VALUES_AS_ARRAY);
     $errors = !$isValid ? $form->getMessages() : null;
     // Merge and replace previous files with new valid files
     $prevFileData = $this->getEmptyUploadData($inputFilter, $previousFiles);
     $newFileData = $this->getNonEmptyUploadData($inputFilter, $data);
     $postFiles = ArrayUtils::merge($prevFileData ?: array(), $newFileData ?: array(), true);
     $post = ArrayUtils::merge($postOther, $postFiles, true);
     // Save form data in session
     $container->setExpirationHops(1, array('post', 'errors', 'isValid'));
     $container->post = $post;
     $container->errors = $errors;
     $container->isValid = $isValid;
     $container->files = $postFiles;
     return $this->redirect($redirect, $redirectToUrl);
 }
开发者ID:tillk,项目名称:vufind,代码行数:41,代码来源:FilePostRedirectGet.php

示例10: 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

示例11: updateAction

 public function updateAction()
 {
     $cronjob = $this->cronManager->find($this->params('id'));
     if (!$cronjob) {
         return $this->notFoundAction();
     }
     $this->cronjobForm->bind($cronjob);
     if ($this->getRequest()->isPost()) {
         $this->cronjobForm->setData($this->getRequest()->getPost());
         if ($this->cronjobForm->isValid()) {
             $data = $this->cronjobForm->getData();
             $this->cronManager->persist($data);
             return $this->redirect()->toRoute('admin/system/cron');
         }
     }
     return new ViewModel(['cronjob' => $cronjob, 'cronjobForm' => $this->cronjobForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:17,代码来源:AdminCron.php

示例12: 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

示例13: 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

示例14: 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

示例15: updateAction

 public function updateAction()
 {
     $group = $this->groupTaskService->find($this->params('id'));
     if (!$group) {
         return $this->notFoundAction();
     }
     $this->groupForm->bind($group);
     if ($this->getRequest()->isPost()) {
         $this->groupForm->setData($this->getRequest()->getPost());
         if ($this->groupForm->isValid()) {
             $group = $this->groupForm->getData();
             $this->groupTaskService->persist($group);
             $this->flashMessenger()->addSuccessMessage('The group has been updated.');
             return $this->redirect()->toRoute('admin/usermanagement/groups');
         }
     }
     return new ViewModel(['group' => $group, 'groupForm' => $this->groupForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:18,代码来源:AdminGroups.php


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