當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Form::handleRequest方法代碼示例

本文整理匯總了PHP中Symfony\Component\Form\Form::handleRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::handleRequest方法的具體用法?PHP Form::handleRequest怎麽用?PHP Form::handleRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Form\Form的用法示例。


在下文中一共展示了Form::handleRequest方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processPostedForm

 /**
  * @param Request $request
  * @param Form $form
  * @param Eleve $eleve
  * @return bool
  */
 private function processPostedForm(Request $request, Form $form, Eleve $eleve, Period $periode)
 {
     $em = $this->getDoctrine()->getManager();
     $form->handleRequest($request);
     if ($form->isValid()) {
         $temporary_taps_to_persist = $eleve->getTaps();
         // retire toutes les inscriptions au TAP pour la période qui ne sont pas
         // et qui n'ont pas été enregistré par le parent
         // dans la nouvelle sélection
         $repo = $em->getRepository('WCSCantineBundle:Eleve');
         $eleve_taps_periode = $repo->findAllTapsForPeriode($eleve, $periode, true);
         foreach ($eleve_taps_periode as $item) {
             if (!$temporary_taps_to_persist->contains($item)) {
                 $em->remove($item);
             }
         }
         // retire toutes les inscriptions à la garderie pour la période qui ne sont pas
         // et qui n'ont pas été enregistré par le parent
         // dans la nouvelle sélection
         $temporary_garderies_to_persist = $eleve->getGarderies();
         $eleve_garderies_periode = $repo->findAllGarderiesForPeriode($eleve, $periode, true);
         foreach ($eleve_garderies_periode as $item) {
             if (!$temporary_garderies_to_persist->contains($item)) {
                 $em->remove($item);
             }
         }
         $eleve->setTapgarderieSigned(true);
         $em->flush();
         return true;
     }
     return false;
 }
開發者ID:WildCodeSchool,項目名稱:projet-gesty,代碼行數:38,代碼來源:TapGarderieController.php

示例2: bindRequest

 /**
  * @param Request $request
  */
 public function bindRequest(Request $request)
 {
     $this->form->handleRequest($request);
     foreach ($this->tabs as $tab) {
         $tab->bindRequest($request);
     }
 }
開發者ID:BranchBit,項目名稱:KunstmaanBundlesCMS,代碼行數:10,代碼來源:TabPane.php

示例3: process

 /**
  * @return bool
  */
 public function process()
 {
     $this->form->handleRequest($this->request);
     if ($this->form->isValid()) {
         return $this->onSuccess();
     }
     return false;
 }
開發者ID:jlm-entreprise,項目名稱:core-bundle,代碼行數:11,代碼來源:FormHandler.php

示例4: processPostedForm

 /**
  * @param Request $request
  * @param Form $form
  * @param Eleve $eleve
  * @return bool
  */
 private function processPostedForm(Request $request, Form $form, Eleve $eleve)
 {
     $em = $this->getDoctrine()->getManager();
     $form->handleRequest($request);
     if ($form->isValid()) {
         // la nouvelle sélection de dates (avec celles déjà présentes en
         // base de données, et les nouvelles à ajouter
         // (cette liste a été mise à jour avec LunchToStringTransformer)
         $lunchesNew = $eleve->getLunches();
         // récupère les réservations actuellement en base de données
         $lunchesOld = $em->getRepository("WCSCantineBundle:Lunch")->findByEleve($eleve);
         // supprime les dates qui ne sont plus sélectionnées
         foreach ($lunchesOld as $lunchOld) {
             if (!$lunchesNew->contains($lunchOld)) {
                 $em->remove($lunchOld);
             }
         }
         $eleve->setCanteenSigned(true);
         // met à jour la fiche élève (le régime alimentaire,...)
         $em->persist($eleve);
         $em->flush();
         return true;
     }
     return false;
 }
開發者ID:WildCodeSchool,項目名稱:projet-gesty,代碼行數:31,代碼來源:CantineController.php

示例5: bindForm

 public function bindForm(Request $request)
 {
     $this->form->handleRequest($request);
     if ($this->form->isValid()) {
         $this->writeTranslationsToFile($request->request->all());
         return true;
     }
     return false;
 }
開發者ID:kokmok,項目名稱:SKCMS-Locale,代碼行數:9,代碼來源:TranslationFilesLoader.php

示例6: handle

 /**
  * @param Form $form
  * @throws MethodNotAllowedException
  * @throws ValidatorException
  */
 protected function handle(Form $form)
 {
     if (false === $this->getRequest()->isMethod('POST')) {
         throw new MethodNotAllowedException(array('POST'), 'Form can be posted only by "POST" method.');
     }
     $form->handleRequest($this->getRequest());
     if (false === $form->isValid()) {
         throw new ValidatorException('Form object validation failed, form is invalid.');
     }
 }
開發者ID:gitter-badger,項目名稱:diamantedesk-application,代碼行數:15,代碼來源:FormHandlerTrait.php

示例7: processForm

 /**
  * @param \Symfony\Component\Form\Form $form
  * @param \Symfony\Component\HttpFoundation\Request $request
  */
 private function processForm(Form $form, Entry $entry, Request $request)
 {
     $form->handleRequest($request);
     if ($form->isValid()) {
         $this->getEm()->persist($entry);
         $this->getEm()->flush();
         return true;
     }
     return false;
 }
開發者ID:dragonito,項目名稱:mental-note,代碼行數:14,代碼來源:EntryController.php

示例8: handleConfigForm

 /**
  * @param Request $request
  * @param Form    $form
  *
  * @return array|boolean
  */
 public function handleConfigForm(Request $request, Form $form)
 {
     if ($request->isMethod('post')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             return $form->getData();
         }
     }
     return false;
 }
開發者ID:blazarecki,項目名稱:stage1,代碼行數:16,代碼來源:ConfigurableProviderTrait.php

示例9: process

 public function process(Form $form, Request $request)
 {
     if (!$request->isMethod('POST')) {
         return false;
     }
     $form->handleRequest($request);
     if ($form->isValid()) {
         return $this->processValidForm($form, $request);
     }
     return false;
 }
開發者ID:bwgraves,項目名稱:forkcms,代碼行數:11,代碼來源:DatabaseHandler.php

示例10: handleFormRequest

 /**
  * @param Form $form
  * @param Request $request
  * @return bool|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 private function handleFormRequest(Form $form, Request $request)
 {
     $form->handleRequest($request);
     if (!$form->isValid()) {
         return false;
     }
     $userEntity = $this->initUser($form->getData());
     $em = $this->getDoctrine()->getManager();
     $em->persist($userEntity);
     $em->flush();
     return true;
 }
開發者ID:vikbert,項目名稱:starwarsevents,代碼行數:17,代碼來源:RegisterController.php

示例11: validate

 /**
  * validate
  *
  * @param Form    $form    Form
  * @param Request $request Request
  *
  * @return boolean
  */
 public function validate(Form $form, Request $request)
 {
     if ($this->hasMethod($request->getMethod())) {
         if ($request->getMethod() != 'POST') {
             $form->submit($request);
         } else {
             $form->handleRequest($request);
         }
         return $form->isValid();
     }
     return false;
 }
開發者ID:sogevia,項目名稱:component-form,代碼行數:20,代碼來源:FormHandler.php

示例12: process

 /**
  * @param Form    $form
  * @param Request $request
  *
  * @return bool
  */
 public function process(Form $form, Request $request)
 {
     if (!$request->isMethod('POST')) {
         return false;
     }
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $data = $form->getData();
         $this->em->persist($data);
         $this->em->flush();
         return true;
     }
     return false;
 }
開發者ID:javihgil,項目名稱:extra-bundle,代碼行數:20,代碼來源:DoctrineUpdateFormHandler.php

示例13: isValid

 private function isValid(Request $request, Form $form)
 {
     $session = $request->getSession();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $sessionData = $session->get(self::SESSION_KEY) ?: array();
             $formData = array_replace_recursive($sessionData, $form->getData());
             $session->set(self::SESSION_KEY, $formData);
             return true;
         }
     }
     return false;
 }
開發者ID:hiroyasu55,項目名稱:ec-cube,代碼行數:14,代碼來源:InstallController.php

示例14: buildFilterQuery

 public function buildFilterQuery()
 {
     $em = $this->getDoctrine()->getManager();
     $qb = $em->createQueryBuilder()->select('a')->from($this->entity, 'a');
     if (null !== $this->filterForm) {
         $this->filterForm->handleRequest($this->request);
         if ($this->filterForm->isSubmitted() && $this->filterForm->isValid()) {
             $data = $this->filterForm->getData();
             foreach ($data as $name => $value) {
                 if (substr($name, 0, 7) === 'filter_') {
                     $this->filtersType[substr($name, 7)] = $value;
                 } else {
                     if (null !== $value) {
                         $this->filters[] = [$name, $value];
                     }
                 }
             }
         }
     }
     foreach ($this->filters as $key => $filter) {
         $filterType = '=';
         if (isset($this->filtersType[$filter[0]])) {
             $filterType = $this->filtersType[$filter[0]];
             $value = $filter[1];
             if ($this->filtersType[$filter[0]] === 'contains') {
                 $value = '%' . $filter[1] . '%';
                 $filterType = 'like';
             }
         }
         if (0 === $key) {
             $qb->where('a.' . $filter[0] . ' ' . $filterType . ' :a_' . $filter[0])->setParameter('a_' . $filter[0], $value);
         } else {
             $qb->andWhere('a.' . $filter[0] . ' ' . $filterType . ' :a_' . $filter[0])->setParameter('a_' . $filter[0], $value);
         }
     }
     return $qb;
 }
開發者ID:matthieuleorat,項目名稱:admin-bundle,代碼行數:37,代碼來源:AdminController.php

示例15: onlyAction

 /**
  * @param Request $request
  * @param string $key
  * @return RedirectResponse|Response
  * @throws NotFoundHttpException
  */
 public function onlyAction(Request $request, $key)
 {
     $ajaxTemplates = $this->container->getParameter('l91.sulu.form.ajax_templates');
     if (!$ajaxTemplates[$key]) {
         throw new NotFoundHttpException();
     }
     $this->form = $this->getFormHandler()->get($key, $request->query->all());
     if ($request->isMethod('post')) {
         $this->form->handleRequest($request);
         if ($this->getFormHandler()->handle($this->form)) {
             return new RedirectResponse('?send=true');
         }
     }
     return $this->render($ajaxTemplates[$key], array('form' => $this->form->createView()));
 }
開發者ID:dominikmatt,項目名稱:sulu-form-bundle,代碼行數:21,代碼來源:FormController.php


注:本文中的Symfony\Component\Form\Form::handleRequest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。