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


PHP Form::isValid方法代碼示例

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


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

 /**
  * @param Form $form
  *
  * @return mixed
  * @throws \Exception
  * @throws \PaymentSuite\PaymentCoreBundle\Exception\PaymentException
  */
 private function processPaymentData(Form $form)
 {
     if ($form->isValid()) {
         $data = $form->getData();
         $paymentMethod = new AuthorizenetMethod();
         $paymentMethod->setCreditCartNumber($data['credit_cart'])->setCreditCartExpirationMonth($data['credit_cart_expiration_month'])->setCreditCartExpirationYear($data['credit_cart_expiration_year']);
         try {
             $this->get('authorizenet.manager')->processPayment($paymentMethod);
             $redirectUrl = $this->container->getParameter('authorizenet.success.route');
             $redirectAppend = $this->container->getParameter('authorizenet.success.order.append');
             $redirectAppendField = $this->container->getParameter('authorizenet.success.order.field');
         } catch (PaymentException $e) {
             /**
              * Must redirect to fail route
              */
             $redirectUrl = $this->container->getParameter('authorizenet.fail.route');
             $redirectAppend = $this->container->getParameter('authorizenet.fail.order.append');
             $redirectAppendField = $this->container->getParameter('authorizenet.fail.order.field');
             throw $e;
         }
     } else {
         /**
          * If form is not valid, fail return page
          */
         $redirectUrl = $this->container->getParameter('authorizenet.fail.route');
         $redirectAppend = $this->container->getParameter('authorizenet.fail.order.append');
         $redirectAppendField = $this->container->getParameter('authorizenet.fail.order.field');
     }
     $redirectData = $redirectAppend ? array($redirectAppendField => $this->get('payment.bridge')->getOrderId()) : array();
     $returnData['redirectUrl'] = $redirectUrl;
     $returnData['redirectData'] = $redirectData;
     return $returnData;
 }
開發者ID:hason,項目名稱:paymentsuite,代碼行數:40,代碼來源:AuthorizenetController.php

示例3: saveCobroForm

 public function saveCobroForm(Form $form, Cobro $cobro, $cuentaId)
 {
     $cuenta = $this->em->getRepository('AppBundle:Cuenta')->find($cuentaId);
     $result = false;
     $message = 'Ocurrion un error al guardar el cobro.';
     $amount = 0;
     $positive = false;
     if ($cuenta && $form->isValid()) {
         $cobro->setCuenta($cuenta);
         $this->em->persist($cobro);
         $cuenta->addPagoAmount($cobro->getMonto());
         $this->em->persist($cuenta);
         $this->em->flush();
         $result = true;
         $message = 'Cobro guardado con exito.';
         if ($cobro->getEnviado()) {
             //send email
             $message .= ' Email enviado correctamente';
         }
         $amount = $cuenta->getFormatedDiferencia();
         if ($cuenta->getDiferencia() < 0) {
             $positive = true;
         }
     }
     return array('result' => $result, 'message' => $message, 'amount' => $amount, 'positive' => $positive, 'cuentaId' => $cuentaId, 'cobro' => $cobro);
 }
開發者ID:rsantellan,項目名稱:bunnies-kinder2,代碼行數:26,代碼來源:CobroService.php

示例4: process

 /**
  *
  * @return boolean
  */
 public function process()
 {
     $this->form->submit($this->request);
     if ($this->form->isValid()) {
         $formData = $this->form->getData();
         $name = (string) $formData->getName();
         if ($name) {
             $this->qb->andWhere($this->qb->expr()->like('p.name', ':name'))->setParameter('name', '%' . $name . '%');
         }
         $text = (string) $formData->getText();
         if ($text) {
             $this->qb->andWhere($this->qb->expr()->orx($this->qb->expr()->like('p.intro', ':intro'), $this->qb->expr()->like('p.content', ':content')))->setParameter('intro', '%' . $text . '%')->setParameter('content', '%' . $text . '%');
         }
         $isPublished = (string) $formData->getIsPublished();
         if ($isPublished) {
             if ($isPublished == 'yes') {
                 $this->qb->andWhere($this->qb->expr()->eq('p.status', ':status'))->setParameter('status', PostStatus::PUBLISHED);
             }
             if ($isPublished == 'no') {
                 $this->qb->andWhere($this->qb->expr()->neq('p.status', ':status'))->setParameter('status', PostStatus::PUBLISHED);
             }
         }
         $order = (string) $formData->getOrder();
         if ($order) {
             $this->qb->orderBy('p.' . $order, 'DESC');
         }
         return true;
     }
     return false;
 }
開發者ID:radutopala,項目名稱:BlogBundle,代碼行數:34,代碼來源:PostFilterHandler.php

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

示例6: testValid

 public function testValid()
 {
     $this->sut->submit(['fullName' => 'James T. Kirk', 'location' => 'San Francisco', 'placeOfBirth' => 'Iowa']);
     foreach ($this->sut as $name => $child) {
         $this->assertTrue($child->isValid(), $name);
     }
     $this->assertTrue($this->sut->isValid());
 }
開發者ID:xtrasmal,項目名稱:iinano,代碼行數:8,代碼來源:ProfileTypeTest.php

示例7: process

 /**
  * @return boolean
  */
 public function process()
 {
     $this->form->submit($this->request);
     if ($this->form->isValid()) {
         $query = $this->form->getData()->getQuery();
         return true;
     }
     return false;
 }
開發者ID:radutopala,項目名稱:BlogBundle,代碼行數:12,代碼來源:SearchHandler.php

示例8: process

 /**
  * @param EntityManager $user
  *
  * @return bool
  */
 public function process(ProjetModel $projet)
 {
     $this->form->setData($projet);
     if ('POST' == $this->request->getMethod()) {
         $this->form->bind($this->request);
         if ($this->form->isValid()) {
             $projet->setUser($this->connectedUser);
             ############ Edit settings ##############
             $DestinationDirectory = __DIR__ . '/../../../../../web/uploads/';
             //specify upload directory ends with / (slash)
             $Quality = 90;
             //jpeg quality
             ##########################################
             //Let's check allowed $ImageType, we use PHP SWITCH statement here
             $ext = $projet->file->getMimeType();
             switch (strtolower($projet->file->getMimeType())) {
                 case 'image/png':
                     //Create a new image from file
                     $CreatedImage = imagecreatefrompng($projet->file->getRealPath());
                     break;
                 case 'image/gif':
                     $CreatedImage = imagecreatefromgif($projet->file->getRealPath());
                     break;
                 case 'image/jpeg':
                 case 'image/pjpeg':
                     $CreatedImage = imagecreatefromjpeg($projet->file->getRealPath());
                     break;
                 default:
                     die('Unsupported File!');
                     //output error and exit
             }
             // Crop and save image to upload directory
             $cropService = $this->cropper;
             $destImage = uniqid() . '.' . $projet->file->guessExtension();
             if (!$cropService->cropImage($projet->getX(), $projet->getY(), $projet->getW(), $projet->getH(), $DestinationDirectory . $destImage, $CreatedImage, $Quality, $projet->file->getMimeType())) {
                 die('Erreur lors du rognage de l\'image');
             }
             $projet->setPhoto($destImage);
             // Create entity project
             $entity = new Projet();
             $entity->setNomprojet($projet->getNomprojet());
             $entity->setDescription($projet->getDescription());
             $entity->setDuree($projet->getDuree());
             $entity->setDaterealisation($projet->getDaterealisation());
             $entity->setGains($projet->getGains());
             $entity->setFinancement($projet->getFinancement());
             $entity->setPhoto($projet->getPhoto());
             $entity->setCout($projet->getCout());
             $entity->setUser($projet->getUser());
             $this->entityManager->persist($entity);
             $this->entityManager->flush();
             return true;
         }
     }
     return false;
 }
開發者ID:WildCodeSchool,項目名稱:projet-wiki_des_maires,代碼行數:61,代碼來源:ProjetHandler.php

示例9: process

 /**
  *
  * @return boolean
  */
 public function process()
 {
     $this->form->submit($this->request);
     if ($this->form->isValid()) {
         $this->entity = $this->form->getData();
         $this->em->persist($this->entity);
         $this->em->flush();
         return true;
     }
     return false;
 }
開發者ID:radutopala,項目名稱:BlogBundle,代碼行數:15,代碼來源:LinkHandler.php

示例10: process

 /**
  *
  * @return boolean
  */
 public function process()
 {
     $this->form->submit($this->request);
     if ($this->form->isValid()) {
         $formData = $this->form->getData();
         if ($name = (string) $formData->name) {
             $this->qb->andWhere($this->qb->expr()->like('t.name', ':name'))->setParameter('name', '%' . $name . '%');
         }
         return true;
     }
     return false;
 }
開發者ID:radutopala,項目名稱:BlogBundle,代碼行數:16,代碼來源:TagFilterHandler.php

示例11: process

 /**
  * @return boolean
  */
 public function process()
 {
     $this->form->submit($this->request);
     if ($this->form->isValid()) {
         $entityModel = $this->form->getData();
         $this->entity->setContent($this->sanitizer->doClean($entityModel->getContent()));
         $this->entity->setUserName($this->sanitizer->doClean($entityModel->getUserName()));
         $this->entity->setUserEmail($this->sanitizer->doClean($entityModel->getUserEmail()));
         $this->entity->setUserWeb($this->sanitizer->doClean($entityModel->getUserWeb()));
         $this->em->persist($this->entity);
         $this->em->flush();
         return true;
     }
     return false;
 }
開發者ID:radutopala,項目名稱:BlogBundle,代碼行數:18,代碼來源:CommentHandler.php

示例12: process

 /**
  *
  * @return boolean
  */
 public function process()
 {
     $this->form->submit($this->request);
     if ($this->form->isValid()) {
         $entityModel = $this->form->getData();
         $file = $entityModel->getFile();
         $fileName = $this->getName() . '.' . $file->getClientOriginalExtension();
         $file->move($this->uploadPath, $fileName);
         $this->entity->setFile($fileName);
         $this->em->persist($this->entity);
         $this->em->flush();
         return true;
     }
     return false;
 }
開發者ID:radutopala,項目名稱:BlogBundle,代碼行數:19,代碼來源:ImageHandler.php

示例13: filterSetAction

 /**
  * @Route("/datapresentation/filter_set", name="datapresentation_filter_set")
  */
 public function filterSetAction(Request $request)
 {
     $this->init($request);
     $this->initForm();
     if ($this->form->isSubmitted() && $this->form->isValid()) {
         $filters = $this->form->getData();
         unset($filters['today']);
         $filtersString = serialize($filters);
         $cookie = new Cookie('filters', $filtersString, time() + 3600 * 24 * 7, '/');
         $response = new Response();
         $response->headers->setCookie($cookie);
         $response->send();
         $this->request->cookies->set('filters', $filtersString);
     }
     return $this->redirectToRoute('datapresentation');
 }
開發者ID:jarold87,項目名稱:orcinus,代碼行數:19,代碼來源:DataPresentationController.php

示例14: process

 /**
  * @param UserInterface $user
  *
  * @return bool
  */
 public function process(UserInterface $user)
 {
     $this->form->setData($user);
     if ('POST' == $this->request->getMethod()) {
         $this->form->bind($this->request);
         if ($this->form->isValid()) {
             $this->onSuccess($user);
             return true;
         }
         // Reloads the user to reset its username. This is needed when the
         // username or password have been changed to avoid issues with the
         // security layer.
         $this->userManager->reloadUser($user);
     }
     return false;
 }
開發者ID:Tagarela76,項目名稱:table4you,代碼行數:21,代碼來源:ProfileFormHandler.php

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


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