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


PHP FormEvent::getForm方法代码示例

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


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

示例1: submit

 public function submit(FormEvent $event)
 {
     $entity = $event->getData();
     if (!empty($entity) && $entity->isLocked()) {
         $event->getForm()->addError(new FormError('error.element_locked'));
     }
 }
开发者ID:thierrymarianne,项目名称:MttBundle,代码行数:7,代码来源:SeasonLockedSubscriber.php

示例2: onSubmit

 /**
  * Reorder the children of the parent form data at $this->name.
  *
  * For whatever reason we have to go through the parent object, just
  * getting the collection from the form event and reordering it does
  * not update the stored order.
  *
  * @param FormEvent $event
  */
 public function onSubmit(FormEvent $event)
 {
     $form = $event->getForm()->getParent();
     $data = $form->getData();
     if (!is_object($data)) {
         return;
     }
     $accessor = PropertyAccess::getPropertyAccessor();
     // use deprecated BC method to support symfony 2.2
     $newCollection = $accessor->getValue($data, $this->name);
     if (!$newCollection instanceof Collection) {
         return;
     }
     /* @var $newCollection Collection */
     $newCollection->clear();
     /** @var $item FormBuilder */
     foreach ($form->get($this->name) as $key => $item) {
         if ($item->get('_delete')->getData()) {
             // do not re-add a deleted child
             continue;
         }
         if ($item->getName() && !is_numeric($item->getName())) {
             // keep key in collection
             $newCollection[$item->getName()] = $item->getData();
         } else {
             $newCollection[] = $item->getData();
         }
     }
 }
开发者ID:jmontoyaa,项目名称:SonataDoctrinePhpcrAdminBundle,代码行数:38,代码来源:CollectionOrderListener.php

示例3: preSubmit

 public function preSubmit(FormEvent $event)
 {
     $data = $event->getData();
     $form = $event->getForm();
     $province_id = array_key_exists('province', $data) ? $data['province'] : null;
     $this->addCityForm($form, $province_id);
 }
开发者ID:sourcevx,项目名称:Test,代码行数:7,代码来源:AddCityFieldSubscriber.php

示例4: onPreSubmit

 public function onPreSubmit(FormEvent $event)
 {
     $form = $event->getForm();
     $data = $event->getData();
     $type = $this->app['orm.em']->getRepository(':Property')->find($data['property'])->getDataType();
     $this->renderFormType($form, $type);
 }
开发者ID:samuvack,项目名称:admin,代码行数:7,代码来源:RelationType.php

示例5: buildForm

 /**
  * Create all diagnosis fields not already set.
  *
  * @param FormEvent $event
  */
 public function buildForm(FormEvent $event)
 {
     $regimen = $event->getData();
     if ($regimen->getId()) {
         $event->getForm()->remove('patient');
     }
     $config = $event->getForm()->get('activities')->getConfig();
     $type = $config->getType()->getName();
     $options = $config->getOptions();
     $qb = $options['options']['query_builder'] = $this->activityRepository->getQueryBuilder();
     // If no diagnosis is present, look for patient.
     if (null === $regimen || null === $regimen->getDiagnosis()) {
         if (null === $regimen->getPatient()) {
             $qb->andWhere('activity.patient IS NULL');
             $qb->andWhere('activity.diagnosis IS NULL');
         } else {
             $qb->andWhere('activity.patient = :patient');
             $qb->andWhere('activity.diagnosis IS NULL');
             $qb->setParameter(':patient', $regimen->getPatient());
         }
     } else {
         $qb->resetDQLPart('where')->where('activity.diagnosis = :diagnosis')->setParameter(':diagnosis', $regimen->getDiagnosis());
     }
     if (($startDate = $regimen->getStartDate()) instanceof DateTime) {
         $qb->andWhere('activity.activityDate >= :startDate')->setParameter(':startDate', $startDate);
     }
     if (($endDate = $regimen->getEndDate()) instanceof DateTime) {
         $qb->andWhere('activity.activityDate <= :endDate')->setParameter(':endDate', $endDate);
     }
     $event->getForm()->add('activities', $type, $options);
 }
开发者ID:upenn-dag,项目名称:patient-repository,代码行数:36,代码来源:DiagnosisActivitiesListener.php

示例6: onPreSubmit

 /**
  * Forbids to erase a value
  *
  * @param FormEvent $event
  */
 public function onPreSubmit(FormEvent $event)
 {
     $data = $event->getData();
     if ($data['file'] instanceof UploadedFile) {
         $event->getForm()->remove('remove');
     }
     if (empty($data['file']) && (!isset($data['remove']) || !$data['remove'])) {
         $event->setData($event->getForm()->getViewData());
     }
 }
开发者ID:it-blaster,项目名称:uploadable-bundle,代码行数:15,代码来源:UploadableType.php

示例7: postSubmit

 /**
  * Listener for the {@link FormEvents::POST_SUBMIT} event.
  *
  * @param FormEvent $event The event object
  */
 public function postSubmit(FormEvent $event)
 {
     if ($event->getForm()->isRoot()) {
         // Collect the submitted data of each form
         $this->dataCollector->collectSubmittedData($event->getForm());
         // Assemble a form tree
         // This is done again after the view is built, but we need it here as the view is not always created.
         $this->dataCollector->buildPreliminaryFormTree($event->getForm());
     }
 }
开发者ID:ayoah,项目名称:symfony,代码行数:15,代码来源:DataCollectorListener.php

示例8: addFees

 public function addFees(FormEvent $event)
 {
     /* @var $billingSpec BillingSpec */
     $billingSpec = $event->getData();
     //Attach a tier form
     if ($billingSpec->getType() == BillingSpec::TYPE_TIER) {
         $event->getForm()->add($this->factory->createNamed('fees', 'collection', $billingSpec->getFees(), array('type' => new TierFeeFormType(), 'allow_add' => true, 'by_reference' => false)));
     } elseif ($billingSpec->getType() == BillingSpec::TYPE_FLAT) {
         $event->getForm()->add($this->factory->createNamed('fees', 'collection', $billingSpec->getFees(), array('type' => new FlatFeeFormType(), 'allow_add' => true, 'by_reference' => false)));
     }
 }
开发者ID:junjinZ,项目名称:wealthbot,代码行数:11,代码来源:BillingSpecFormType.php

示例9: postSubmit

 /**
  * {@inheritdoc}
  */
 public function postSubmit(FormEvent $event)
 {
     $entity = $event->getForm()->getParent()->getData();
     if (!$entity instanceof CaseMailboxProcessSettings || !$entity->getMailbox()) {
         return;
     }
     /** @var Tag[] $tags */
     $tags = array_merge($event->getForm()->get('all')->getData(), $event->getForm()->get('owner')->getData());
     foreach ($tags as $tag) {
         $tag->setOrganization($entity->getMailbox()->getOrganization());
     }
 }
开发者ID:mehulsbhatt,项目名称:crm,代码行数:15,代码来源:CaseMailboxProcessSettingsTagSubscriber.php

示例10: hasPrimaryBehaviour

 /**
  * @param FormEvent $event
  *
  * @return bool
  */
 protected function hasPrimaryBehaviour(FormEvent $event)
 {
     if (!$event->getForm()->getConfig()->getOption('handle_primary')) {
         return false;
     }
     /** @var FormInterface $child */
     foreach ($event->getForm() as $child) {
         $dataClass = $child->getConfig()->getDataClass();
         if ($dataClass && !in_array('Oro\\Bundle\\FormBundle\\Entity\\PrimaryItem', class_implements($dataClass))) {
             return false;
         }
     }
     return true;
 }
开发者ID:Maksold,项目名称:platform,代码行数:19,代码来源:CollectionTypeSubscriber.php

示例11: checkTeamMembers

 /**
  * Form event handler that makes sure the participants are actually members
  * of the specified team
  * @param  FormEvent $event
  * @return void
  */
 public function checkTeamMembers(FormEvent $event)
 {
     $players = $event->getForm()->get('participants');
     $team = $event->getForm()->get('team')->getData();
     if (!$team || !$team instanceof \Model || !$team->isValid()) {
         return;
     }
     foreach ($players->getData() as $player) {
         if ($player && !$team->isMember($player->getId())) {
             $message = "{$player->getUsername()} is not a member of {$team->getName()}";
             $players->addError(new FormError($message));
         }
     }
 }
开发者ID:allejo,项目名称:bzion,代码行数:20,代码来源:MatchTeamType.php

示例12: buildCredentials

 /**
  * @param FormEvent $event
  */
 public function buildCredentials(FormEvent $event)
 {
     /** @var array $data */
     $data = $event->getData();
     if (is_null($data)) {
         return;
     }
     $propertyPath = is_array($data) ? '[factoryName]' : 'factoryName';
     $factoryName = PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath);
     if (empty($factoryName)) {
         return;
     }
     $form = $event->getForm();
     $form->add('config', 'form');
     $configForm = $form->get('config');
     $gatewayFactory = $this->registry->getGatewayFactory($factoryName);
     $config = $gatewayFactory->createConfig();
     $propertyPath = is_array($data) ? '[config]' : 'config';
     $firstTime = false == PropertyAccess::createPropertyAccessor()->getValue($data, $propertyPath);
     foreach ($config['payum.default_options'] as $name => $value) {
         $propertyPath = is_array($data) ? "[config][{$name}]" : "config[{$name}]";
         if ($firstTime) {
             PropertyAccess::createPropertyAccessor()->setValue($data, $propertyPath, $value);
         }
         $type = is_bool($value) ? 'checkbox' : 'text';
         $options = array();
         $options['required'] = in_array($name, $config['payum.required_options']);
         $configForm->add($name, $type, $options);
     }
     $event->setData($data);
 }
开发者ID:Raxer971,项目名称:challenge,代码行数:34,代码来源:GatewayConfigType.php

示例13:

 function it_adds_payment_methods_choice_to_the_form(FormEvent $event, FormInterface $form, PaymentInterface $payment)
 {
     $event->getForm()->willReturn($form);
     $event->getData()->willReturn($payment);
     $form->add('method', Argument::type('string'), ['label' => 'sylius.form.checkout.payment_method', 'subject' => $payment, 'expanded' => true])->shouldBeCalled();
     $this->preSetData($event);
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:7,代码来源:AddPaymentMethodsFormSubscriberSpec.php

示例14: onPreSetData

 public function onPreSetData(FormEvent $event)
 {
     $form = $event->getForm();
     if ('contact' === $form->getName()) {
         $form->add('sample_form', 'text');
     }
 }
开发者ID:shinichi-takahashi,项目名称:eccube3-sample-plugin,代码行数:7,代码来源:SampleForm.php

示例15: preSetData

 public function preSetData(FormEvent $event)
 {
     $form = $event->getForm();
     $form->add('customData', CustomFormType::class, ['callback' => function (FormBuilderInterface $builder) {
         return $this->customFormModel->constructForm($builder);
     }, 'validationCallback' => 'validateForm']);
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:7,代码来源:CustomFormEventSubscriber.php


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