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


PHP FormInterface::bind方法代码示例

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


在下文中一共展示了FormInterface::bind方法的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: 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

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

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

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

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

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

示例8: editAction

 public function editAction()
 {
     $project = $this->projectRepository->find($this->params('projectId'));
     if ($project === null) {
         $this->getResponse()->setStatusCode(404);
         return;
     }
     $this->projectForm->get('client')->setValue($project->getClient()->getName());
     $this->projectForm->bind($project);
     if ($this->getRequest()->isPost()) {
         $this->projectForm->setData($this->getRequest()->getPost());
         if ($this->projectForm->isValid()) {
             $this->projectService->persist($this->projectForm->getData());
             $this->redirect()->toRoute('clients/show', ['clientId' => $project->getClient()->getId()], ['fragment' => 'project-table']);
         }
     }
     return new ViewModel(['form' => $this->projectForm]);
 }
开发者ID:DavidHavl,项目名称:Ajasta,代码行数:18,代码来源:ProjectController.php

示例9: updateAction

 public function updateAction()
 {
     /** @var \ZourceUser\Entity\Account $account */
     $account = $this->accountTaskService->find($this->params('id'));
     if (!$account) {
         return $this->notFoundAction();
     }
     $this->accountForm->bind($account);
     if ($this->getRequest()->isPost()) {
         $this->accountForm->setData($this->getRequest()->getPost());
         if ($this->accountForm->isValid()) {
             $account = $this->accountForm->getData();
             $this->accountTaskService->persist($account);
             return $this->redirect()->toRoute('admin/usermanagement/accounts');
         }
     }
     return new ViewModel(['account' => $account, 'accountForm' => $this->accountForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:18,代码来源:AdminAccounts.php

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

示例11: getForm

 /**
  * get form
  * 
  * @param int $id
  * @return \Zend\Form\FormInterface
  */
 public function getForm($id = 0)
 {
     if ((int) $id > 0) {
         $entity = $this->find($id);
         if ($entity) {
             $this->form->bind($entity);
         }
     }
     return $this->form;
 }
开发者ID:phpfriq,项目名称:zf-crud-helper,代码行数:16,代码来源:AbstractEntityService.php

示例12: updateAction

 public function updateAction()
 {
     $application = $this->applicationService->getApplication($this->params('id'));
     if (!$application) {
         return $this->notFoundAction();
     }
     if ($application->getAccount() !== $this->zourceAccount()) {
         return $this->notFoundAction();
     }
     $this->applicationForm->bind($application);
     if ($this->getRequest()->isPost()) {
         $this->applicationForm->setData($this->getRequest()->getPost());
         if ($this->applicationForm->isValid()) {
             $updatedApplication = $this->applicationForm->getData();
             $this->applicationService->persistApplication($updatedApplication);
             return $this->redirect()->toRoute('settings/applications');
         }
     }
     return new ViewModel(['application' => $application, 'applicationForm' => $this->applicationForm]);
 }
开发者ID:zource,项目名称:zource,代码行数:20,代码来源:DeveloperApplication.php

示例13: editAction

 public function editAction()
 {
     $request = $this->getRequest();
     $page = $this->pageService->findPage($this->params('id'));
     $this->pageForm->bind($page);
     if ($request->isPost()) {
         $this->pageForm->setData($request->getPost());
         if ($this->pageForm->isValid()) {
             try {
                 $this->pageService->savePage($page);
                 return $this->redirect()->toRoute('admin');
             } catch (\Exception $e) {
                 // Some DB Error happened
                 $view = new ViewModel(array('message' => $e->getMessage()));
                 $view->setTemplate('error/error');
                 return $view;
             }
         }
     }
     return new ViewModel(array('form' => $this->pageForm));
 }
开发者ID:edorosh,项目名称:dcms,代码行数:21,代码来源:WriteController.php

示例14: mapEntity

 /**
  * Maps entity property to forms or child containers.
  *
  * @param \Zend\Form\FormInterface $form
  * @param \Core\Entity\EntityInterface $entity
  * @param string $property
  * @return void
  */
 protected function mapEntity($form, $entity, $property)
 {
     if (false === $property) {
         return;
     }
     if (true === $property) {
         $mapEntity = $entity;
     } else {
         if ($entity->hasProperty($property) || is_callable([$entity, "get{$property}"])) {
             $getter = "get{$property}";
             $mapEntity = $entity->{$getter}();
         } else {
             return;
         }
     }
     if ($form instanceof Container) {
         $form->setEntity($mapEntity);
     } else {
         $form->bind($mapEntity);
     }
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:29,代码来源:Container.php

示例15: bindForm

 protected function bindForm(FormInterface $form)
 {
     $form->setAttribute('type', 'create');
     $id = $this->getIdentifier();
     if ($id !== false) {
         $entity = $this->entityService->getEntityByIdentifier($id);
         if (!$entity) {
             //404
         }
         $form->setAttribute('type', 'edit');
     } else {
         $entityClass = $this->entityClass;
         $entity = new $entityClass();
     }
     $form->bind($entity);
     return $form;
 }
开发者ID:nobesnickr,项目名称:ApiTimesheets,代码行数:17,代码来源:FormController.php


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