当前位置: 首页>>代码示例>>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;未经允许,请勿转载。