isValid() публичный метод

Returns whether the field is valid.
public isValid ( ) : boolean
Результат boolean
Пример #1
2
 /**
  * @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;
 }
 /**
  * @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;
 }
Пример #3
1
 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);
 }
Пример #4
0
 /**
  *
  * @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;
 }
Пример #5
0
 /**
  * @return bool
  */
 public function process()
 {
     $this->form->handleRequest($this->request);
     if ($this->form->isValid()) {
         return $this->onSuccess();
     }
     return false;
 }
Пример #6
0
 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());
 }
Пример #7
0
 /**
  * @return boolean
  */
 public function process()
 {
     $this->form->submit($this->request);
     if ($this->form->isValid()) {
         $query = $this->form->getData()->getQuery();
         return true;
     }
     return false;
 }
 /**
  * @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;
 }
Пример #9
0
 /**
  *
  * @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;
 }
Пример #10
0
 /**
  *
  * @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;
 }
Пример #11
0
 /**
  * @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;
 }
Пример #12
0
 /**
  *
  * @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;
 }
 /**
  * @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');
 }
Пример #14
0
 /**
  * @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;
 }
 /**
  * @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;
 }
Пример #16
0
 public function process()
 {
     if ($this->form->isValid()) {
         if ('POST' == $this->request->getMethod()) {
             /** @var Apply $apply */
             $apply = $this->form->getData();
             $apply_email = $this->em->getRepository('ESNHRBundle:Apply')->findOneByEmail($apply->getEmail());
             $apply_name = $this->em->getRepository('ESNHRBundle:Apply')->findBy(array("firstname" => $apply->getFirstname(), "lastname" => $apply->getLastname()));
             if (!$apply_email && !$apply_name) {
                 $this->onSuccess($apply);
                 return true;
             } else {
                 $this->container->get('session')->getFlashBag()->add('error', 'Vous êtes déjà enregistré dans notre base de données, il est inutile de postuler plusieurs fois.');
             }
         }
     }
     return false;
 }
Пример #17
0
 private function handleForm(Request $request, Form $form, $id, $command)
 {
     $form->submit($request);
     if ($form->isValid()) {
         $this->handleCommand($command);
         return $this->redirectView($this->router->generate('get_game', array('id' => $id)), Codes::HTTP_CREATED);
     }
     return $form;
 }
Пример #18
0
 public function bindForm(Request $request)
 {
     $this->form->handleRequest($request);
     if ($this->form->isValid()) {
         $this->writeTranslationsToFile($request->request->all());
         return true;
     }
     return false;
 }
Пример #19
0
 public function handleForm(Form $form, &$object)
 {
     $entityManager = $this->registry->getManager();
     if ($form->isValid()) {
         $entityManager->persist($object);
         $entityManager->flush();
         $this->session->getFlashBag()->add('success', 'L\'élément a bien été sauvegardé');
     }
     return $object;
 }
 /**
  * @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;
 }
 /**
  * @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.');
     }
 }
Пример #22
0
 /**
  * @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;
 }
Пример #23
0
 /**
  * フォームのバリデーションを行う
  * ※ServiceクラスでEntityのバリデーションを行っているが、
  * FormTypeクラスで設定したチェックや、CSRFトークンのチェックは
  * $form->isValid()でないと検証できないため、
  * フォームの検証の場合、本メソッドを使用すること
  *
  * @param Form $form
  * @throws FormValidationException
  */
 private function tryFormValidate(Form $form)
 {
     if (!$form->isValid()) {
         $exception = new FormValidationException();
         foreach ($form->getErrors(true, true) as $error) {
             $exception->addErrorMessage($error->getMessage());
         }
         throw $exception;
     }
 }
Пример #24
0
 public function process()
 {
     if ($this->form->isValid()) {
         if ('POST' == $this->request->getMethod()) {
             $recruiters = $this->em->getRepository('ESNUserBundle:User')->findRecruiters();
             /** @var ArrayCollection $recruiters_selected */
             $recruiters_selected = $this->form->get('esner')->getData();
             /** @var User $recruiter */
             foreach ($recruiters as $recruiter) {
                 if (!$recruiters_selected->contains($recruiter)) {
                     $recruiter->removeRole(User::ROLE_RECRUITER);
                 }
             }
             $this->onSuccess($recruiters_selected);
             $this->em->flush();
             return true;
         }
     }
     return false;
 }
Пример #25
0
 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;
 }
Пример #26
0
 /**
  *
  * @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('l.name', ':name'))->setParameter('name', '%' . $name . '%');
         }
         if ($isPublished = (string) $formData->isPublished) {
             if ($isPublished == 'yes') {
                 $this->qb->andWhere($this->qb->expr()->like('l.isPublished', ':isPublished'))->setParameter('isPublished', 1);
             }
             if ($isPublished == 'no') {
                 $this->qb->andWhere($this->qb->expr()->like('l.isPublished', ':isPublished'))->setParameter('isPublished', 0);
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Processes the form with the request
  *
  * @param Form $form
  * @return Message|false the sent message if the form is bound and valid, false otherwise
  */
 public function process(Form $form)
 {
     if ('POST' !== $this->request->getMethod()) {
         return false;
     }
     $form->bindRequest($this->request);
     if ($form->isValid()) {
         return $this->processValidForm($form);
     }
     return false;
 }
Пример #28
0
 /**
  * Process current form
  * @return boolean
  */
 public function process()
 {
     $success = false;
     if ($this->request->getMethod() == 'POST' || $this->request->getMethod() == 'PUT') {
         // Correct HTTP method => try to process form
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             // Form is valid => create or update the path
             $this->data = $this->form->getData();
             if ($this->request->getMethod() == 'POST') {
                 // Create path
                 $success = $this->create();
             } else {
                 // Edit existing path
                 $success = $this->edit();
             }
         }
     }
     return $success;
 }
Пример #29
0
 /**
  * @param Form $form
  * @param Comment $comment
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 private function processCommentForm(Form $form, Comment $comment, Request $request)
 {
     $slug = $comment->getPost()->getSlug();
     if ($form->isValid()) {
         $this->getEm()->persist($comment);
         $this->getEm()->flush();
         $param = ['slug' => $slug];
         $this->addSuccess("lkeblog.success.comment.add");
         return $this->redirectToRoute("lke_blog_post_view", $param);
     }
     return $this->viewAction($request, $slug);
 }
 /**
  * @param Form    $form
  * @param Request $request
  * @param array   $options
  *
  * @return bool
  */
 public function handle(Form $form, Request $request, array $options = null)
 {
     if (!$request->isMethod('POST')) {
         return false;
     }
     $form->bind($request->request->get($form->getName()));
     if (!$form->isBound() || !$form->isValid()) {
         return false;
     }
     $this->usermanager->createUser($form->getData()->getUser());
     return true;
 }