当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::isSubmitted方法代码示例

本文整理汇总了PHP中Symfony\Component\Form\Form::isSubmitted方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::isSubmitted方法的具体用法?PHP Form::isSubmitted怎么用?PHP Form::isSubmitted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Form\Form的用法示例。


在下文中一共展示了Form::isSubmitted方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

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

示例2: createView

 public function createView(Form $form, $template, $parameters, $extraParameters = [])
 {
     $html = $this->templating->render($template, $parameters);
     $response = new JsonResponse();
     $response->setData(array_merge($extraParameters, ['submitted' => $form->isSubmitted(), 'errors' => count($form->getErrors(true)), 'html' => $html]));
     return $response;
 }
开发者ID:alpixel,项目名称:AlpixelFormBundle,代码行数:7,代码来源:ModalFormBuilder.php

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

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

示例5: processForm

 /**
  * @param Request $request
  * @param Form $form
  * @param $entity
  * @return bool
  */
 private function processForm(Request $request, Form $form, ActivityBase $entity)
 {
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $key = $request->get('activity') . '_list_eleves';
         $this->setSessionValue($key, $request->get("list_eleves"));
         $entity->setStatus(ActivityBase::STATUS_NOT_REGISTERED);
         $entity->setDate($this->getDateDay());
         $this->mapper->preUpdateEntity($entity);
         $em = $this->getDoctrineManager();
         $em->persist($entity);
         $em->flush();
         return true;
     }
     return false;
 }
开发者ID:WildCodeSchool,项目名称:projet-gesty,代码行数:22,代码来源:ListViewBuilder.php

示例6: create

 /**
  * Handle CostumerType submission and/or persist and update a costumer entity
  *
  * @param  CostumerType|Costumer                 $form A Form instance of a costumer entity
  * @return bool|Costumer|ConstraintViolationList       Return false when form validation errors,
  *                                                     a Costumer instance when created successfully
  *                                                     or a error list when entity has validation errors
  */
 public function create(Costumer $costumer, Form $form = null, Request $request = null)
 {
     $canStore = true;
     if ($form !== null && $request !== null) {
         // Handle request and validate the submitted form (if submitted)
         $form->handleRequest($request);
         if ($form->isSubmitted()) {
             if (!$form->isValid()) {
                 return false;
             }
         } else {
             $canStore = false;
         }
     } elseif ($form !== null && $request === null) {
         throw new \Exception("The 'request' parameter can't be null if the 'form' parameter was defined");
     } else {
         $validationGroups = null;
         // [];
         // Validate the costumer entity using validation service
         $validator = $this->getValidator();
         $errors = $validator->validate($costumer, null, $validationGroups);
         if (count($errors) > 0) {
             return $errors;
         }
     }
     // Persist costumer
     if ($canStore == true) {
         $conn = $this->getDoctrine()->getConnection();
         $objectManager = $this->getDoctrine()->getManager();
         try {
             $conn->beginTransaction();
             if ($costumer->getId() === null) {
                 $objectManager->persist($costumer);
             }
             $objectManager->flush($costumer);
             $conn->commit();
             return $costumer;
         } catch (\Exception $e) {
             $conn->rollBack();
             throw $e;
         }
     }
     return null;
 }
开发者ID:williamurbano,项目名称:store,代码行数:52,代码来源:CostumerHandler.php

示例7: testIsSubmitted

 public function testIsSubmitted()
 {
     $form = new Form('author', array('validator' => $this->validator));
     $this->assertFalse($form->isSubmitted());
     $form->submit(array('firstName' => 'Bernhard'));
     $this->assertTrue($form->isSubmitted());
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:7,代码来源:FormTest.php

示例8: checkSaveForm

 /**
  * 
  * @param Request $r
  * @param Form $form
  * @param boolean $save
  * @param array $callbackBefore - Array con el método a llamar key = method y un array de parámetros
  * @param array $callbackAfter
  * @return boolean
  */
 protected function checkSaveForm(Request $r, Form &$form, $save = true, $callbackBefore = null, $callbackAfter = null)
 {
     $form->handleRequest($r);
     if ($save && $form->isSubmitted() && $form->isValid()) {
         $obj = $form->getData();
         $this->callBackExec($form, $callbackBefore);
         if (\method_exists($obj, 'beforeSave')) {
             $obj->beforeSave();
         }
         $this->persist($obj);
         if (\method_exists($obj, 'afterSave')) {
             if ($obj->afterSave() == 2) {
                 $this->persist($obj);
             }
         }
         $this->callBackExec($form, $callbackAfter);
         return true;
     } else {
         if ($form->isSubmitted() && !$form->isValid()) {
             return false;
         }
     }
     return null;
 }
开发者ID:kimerikal,项目名称:util-bundle,代码行数:33,代码来源:UtilController.php

示例9: getListData

 /**
  * Get list data. Process filters if submitted.
  *
  * @param Form $filter
  * @return \RunOpenCode\ExchangeRate\Contract\RateInterface[]
  */
 protected function getListData(Form $filter)
 {
     if ($filter->isSubmitted() && $filter->isValid()) {
         return $this->repository->all($filter->getData());
     }
     return $this->repository->all();
 }
开发者ID:RunOpenCode,项目名称:exchange-rate-bundle,代码行数:13,代码来源:ExchangeRateController.php


注:本文中的Symfony\Component\Form\Form::isSubmitted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。