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


PHP Form\Form类代码示例

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


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

示例1: handleFlashErrors

 public static function handleFlashErrors(SymfonyForm $form, $identifier)
 {
     $errors = self::$app['flashbag']->get('form.' . $identifier . '.errors');
     foreach ($errors as $error) {
         $form->addError(new FormError($error));
     }
 }
开发者ID:pinodex,项目名称:boardy,代码行数:7,代码来源:Form.php

示例2: addField

 protected function addField(Form $form, $municipio)
 {
     $formOptions = array('class' => 'SiSuCuentaBundle:Parroquia', 'empty_value' => '-- Seleccionar --', 'attr' => array('class' => 'usuario_parroquia'), 'required' => true, 'label' => 'Parroquia', 'query_builder' => function (EntityRepository $er) use($municipio) {
         return $er->createQueryBuilder('parroquia')->where('parroquia.municipio = :municipio')->setParameter('municipio', $municipio);
     });
     $form->add('parroquia', 'entity', $formOptions);
 }
开发者ID:eddg3110,项目名称:Req_1_CRUD,代码行数:7,代码来源:AddParroquiaFieldSubscriber.php

示例3: convertFormToArray

 private function convertFormToArray(GenericSerializationVisitor $visitor, Form $data)
 {
     $isRoot = null === $visitor->getRoot();
     $form = new \ArrayObject();
     $errors = [];
     foreach ($data->getErrors() as $error) {
         $errors[] = $this->getErrorMessage($error);
     }
     if (!empty($errors)) {
         $form['errors'] = $errors;
     }
     $children = [];
     foreach ($data->all() as $child) {
         if ($child instanceof Form) {
             $children[$child->getName()] = $this->convertFormToArray($visitor, $child);
         }
     }
     if (!empty($children)) {
         $form['children'] = $children;
     }
     if ($isRoot) {
         $visitor->setRoot($form);
     }
     return $form;
 }
开发者ID:koesie10,项目名称:LuaSerializer,代码行数:25,代码来源:LuaFormHandler.php

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

示例5: getErrorMessages

 protected function getErrorMessages(\Symfony\Component\Form\Form $form, $name)
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         $errors[] = $error->getMessage();
     }
     foreach ($form->all() as $child) {
         $type = $child->getConfig()->getType()->getName();
         if ($child->count() && $type !== 'choice') {
             $childErrors = $this->getErrorMessages($child, $child->getName());
             if (sizeof($childErrors)) {
                 $errors = array_merge($errors, $childErrors);
             }
         } else {
             if (!$child->isValid()) {
                 if ($name == "responsable1" || $name == "responsable2") {
                     $errors[$child->getParent()->getParent()->getName() . '_' . $name . '_' . $child->getName()] = $this->getErrorMessages($child, $child->getName());
                 } else {
                     $errors[$name . '_' . $child->getName()] = $this->getErrorMessages($child, $child->getName());
                 }
             }
         }
     }
     return $errors;
 }
开发者ID:JM-PFC,项目名称:CEIP-ST,代码行数:25,代码来源:FestivosController.php

示例6: process

 /**
  * {@inheritdoc}
  */
 public function process(Request $request, $grantType = 'password')
 {
     $account = $this->records->getAccountByEmail($this->submittedForm->get('email')->getData());
     if (!$account) {
         return null;
     }
     $oauth = $this->records->getOauthByGuid($account->getGuid());
     $requestPassword = $this->submittedForm->get('password')->getData();
     if ($this->isValidPassword($oauth, $requestPassword) === false) {
         return null;
     }
     $accessToken = $this->provider->getAccessToken('password', ['guid' => $account->getGuid()]);
     $this->session->addAccessToken('local', $accessToken)->createAuthorisation($account->getGuid());
     $request->query->set('code', Uuid::uuid4()->toString());
     try {
         parent::process($request, $grantType);
         $this->finish($request);
         $this->feedback->info('Login successful.');
     } catch (DisabledAccountException $ex) {
         $this->session->addRedirect($this->urlGenerator->generate('authenticationLogin'));
         if ($this->session->getAuthorisation()) {
             $this->dispatchEvent(MembersEvents::MEMBER_LOGIN_FAILED_ACCOUNT_DISABLED, $this->session->getAuthorisation());
         }
     }
     return $this->session->popRedirect()->getResponse();
 }
开发者ID:bolt,项目名称:Members,代码行数:29,代码来源:Local.php

示例7: persistTranslations

 public function persistTranslations(Form $form, $class, $field, $id, $locales, $userLocale)
 {
     $translations = $form->getData();
     $em = $this->em;
     $repository = $em->getRepository($class);
     $entity = $repository->find($id);
     // loop on locales
     // parse form data
     // get data stored in db
     // set form data on object if needed
     foreach ($locales as $locale) {
         if (array_key_exists($locale, $translations) && $translations[$locale] !== NULL) {
             $entity->setTranslatableLocale($locale);
             $em->refresh($entity);
             $postedValue = $translations[$locale];
             $storedValue = $this->getField($entity, $field);
             if ($storedValue !== $postedValue) {
                 $this->setField($entity, $field, $postedValue);
                 $em->flush();
             }
         }
     }
     // switch entity locale back to user's locale
     $this->setEntityToUserLocale($entity, $userLocale);
 }
开发者ID:benedicthelfer,项目名称:translatable-form-field,代码行数:25,代码来源:TranslatableFieldManager.php

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

示例9: formIsSubmitted

 /**
  * @param Form $form
  * @param RuleAction $action
  * @return void
  */
 public function formIsSubmitted(Form $form, RuleAction $action)
 {
     $params = $this->getParams($action);
     $category = $form->get('category')->getData();
     $params['category_id'] = $category->getId();
     $action->setRawParams($params);
 }
开发者ID:jaapjansma,项目名称:homefinance,代码行数:12,代码来源:SetCategory.php

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

示例11: onCreateSuccess

 protected function onCreateSuccess(Form $form)
 {
     $this->container->get('lichess_comment.authorname_persistence')->persistCommentInSession($form->getData());
     $response = parent::onCreateSuccess($form);
     $this->container->get('lichess_comment.authorname_persistence')->persistCommentInCookie($form->getData(), $response);
     return $response;
 }
开发者ID:hafeez3000,项目名称:lichess,代码行数:7,代码来源:CommentController.php

示例12: removeExtraFields

 /**
  * Get rid on any fields that don't appear in the form
  *
  * @param Request $request
  * @param Form $form
  */
 protected function removeExtraFields(Request $request, Form $form)
 {
     $data = $request->request->all();
     $children = $form->all();
     $data = array_intersect_key($data, $children);
     $request->request->replace($data);
 }
开发者ID:dark-bm,项目名称:mdtgeneratorbundle,代码行数:13,代码来源:MDTController.php

示例13: createLoginForm

 private function createLoginForm($operator = null)
 {
     $form = new Form('login', array('validator' => $this->get('validator')));
     $form->add(new TextField('email'));
     $form->add(new PasswordField('passwd'));
     return $form;
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:7,代码来源:AdminController.php

示例14:

 function it_does_not_remove_user_form_type_if_users_data_is_submitted(FormEvent $event, Form $form)
 {
     $event->getData()->willReturn(['user' => ['plainPassword' => 'test']]);
     $event->getForm()->shouldNotBeCalled();
     $form->remove('user')->shouldNotBeCalled();
     $this->preSubmit($event);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:7,代码来源:AddUserFormSubscriberSpec.php

示例15: aggregatePluralValues

 /**
  * @param array $data
  * @param Form $form
  * @return string
  */
 protected function aggregatePluralValues(&$data, $form)
 {
     $labelManager = $this->labelManager;
     $labelValue = '';
     $standardRules = array();
     $explicitRules = array();
     foreach ($data as $property => $value) {
         if (0 === strpos($property, self::PLURAL_FIELD_PREFIX)) {
             $pluralForm = substr($property, strlen(self::PLURAL_FIELD_PREFIX));
             if (is_numeric($pluralForm)) {
                 $standardRules[$pluralForm] = $value;
             } else {
                 $explicitRules[$pluralForm] = sprintf('%s %s', $labelManager->reverseTransformInterval($pluralForm), $value);
             }
             $form->remove($property);
             unset($data[$property]);
         }
     }
     if ($standardRules) {
         $labelValue = implode('|', $standardRules);
         if ($explicitRules) {
             $labelValue .= '|' . implode('|', $explicitRules);
         }
     } elseif ($explicitRules) {
         $labelValue = implode('|', $explicitRules);
     }
     return $labelValue;
 }
开发者ID:7rin0,项目名称:BigfootCoreBundle,代码行数:33,代码来源:AbstractTranslatableLabelType.php


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