本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例5: process
/**
* @return bool
*/
public function process()
{
$this->form->handleRequest($this->request);
if ($this->form->isValid()) {
return $this->onSuccess();
}
return false;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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');
}
示例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;
}
示例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;
}