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


PHP FormEvent::getData方法代码示例

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


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

示例1: preSetData

 public function preSetData(FormEvent $event)
 {
     $data = $event->getData();
     $form = $event->getForm();
     $estado = ($data and $data->getEstado()) ? $data->getEstado() : null;
     $this->addField($form, $estado);
 }
开发者ID:eddg3110,项目名称:Req_1_CRUD,代码行数:7,代码来源:AddEstadoFieldSubscriber.php

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

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

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

 /**
  * @param FormEvent $event
  */
 public function postSubmit(FormEvent $event)
 {
     $accessor = PropertyAccess::createPropertyAccessor();
     $format = $accessor->getValue($event->getData(), $this->formatField);
     $source = $accessor->getValue($event->getData(), $this->sourceField);
     // make sure the listener works with array
     $data = $event->getData();
     $accessor->setValue($data, $this->targetField, $this->pool->transform($format, $source));
     $event->setData($data);
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:13,代码来源:FormatterListener.php

示例6: onPreSubmit

 /**
  * @param FormEvent $event
  */
 public function onPreSubmit(FormEvent $event)
 {
     $data = $event->getData();
     $grid = $event->getForm()->getConfig()->getOption('grid');
     if (isset($data['reset'])) {
         $this->submittedData = $grid->getData();
     } else {
         $this->submittedData = array_merge($this->filterManager->get($grid), $event->getData());
     }
     $event->setData($this->submittedData);
 }
开发者ID:php-lug,项目名称:lug,代码行数:14,代码来源:PersistentGridSubscriber.php

示例7: onSubmit

 /**
  * Method called on Form\FormEvents::SUBMIT
  * @param  Form\FormEvent $event
  */
 public function onSubmit(Form\FormEvent $event)
 {
     $data = $event->getData();
     if (false == $data['deliverToDifferent']) {
         $data['delivery'] = clone $data['billing'];
         $data['delivery']->type = 'delivery';
         $data['delivery']->id = 'delivery';
         $event->setData($data);
     }
     $this->validateCountry($event->getForm(), $event->getData());
 }
开发者ID:mothership-ec,项目名称:cog-mothership-ecommerce,代码行数:15,代码来源:CheckoutAddressesForm.php

示例8: submit

 /**
  * Field logic : set actual object in form or handle new file creation
  *
  * @param \Symfony\Component\Form\FormEvent $event
  */
 public function submit(FormEvent $event)
 {
     $form = $event->getForm();
     if ($form->getNormData() instanceof BaseFileInterface && !$event->getData() instanceof UploadedFile) {
         $event->setData($form->getNormData());
     }
     if ($event->getData() instanceof UploadedFile) {
         $handler = $this->handlerManager->getHandler($form->getParent()->getConfig()->getDataClass(), $form->getName());
         $datas = $handler->create($event->getData());
         $event->setData($datas);
     }
     if (is_string($event->getData())) {
         $event->setData(null);
     }
 }
开发者ID:P3PO,项目名称:VlabsMediaBundle,代码行数:20,代码来源:BaseFileListener.php

示例9:

 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

示例10: onBindData

 public function onBindData(FormEvent $event)
 {
     $advisorCode = $event->getData();
     $advisorCode->setCustodian($this->custodian);
     $advisorCode->setCustodianId($this->custodian->getId());
     $advisorCode->setRiaCompany($this->riaCompany);
 }
开发者ID:junjinZ,项目名称:wealthbot,代码行数:7,代码来源:AdvisorCodeFormType.php

示例11: onBind

 /**
  * @param \Symfony\Component\Form\FormEvent $event
  */
 public function onBind(FormEvent $event)
 {
     $collection = $event->getForm()->getData();
     $data = $event->getData();
     // looks like there is no way to remove other listeners
     $event->stopPropagation();
     if (!$collection) {
         $collection = $data;
     } elseif (count($data) === 0) {
         $this->modelManager->collectionClear($collection);
     } else {
         // merge $data into $collection
         foreach ($collection as $entity) {
             if (!$this->modelManager->collectionHasElement($data, $entity)) {
                 $this->modelManager->collectionRemoveElement($collection, $entity);
             } else {
                 $this->modelManager->collectionRemoveElement($data, $entity);
             }
         }
         foreach ($data as $entity) {
             $this->modelManager->collectionAddElement($collection, $entity);
         }
     }
     $event->setData($collection);
 }
开发者ID:kwuerl,项目名称:SonataAdminBundle,代码行数:28,代码来源:MergeCollectionListener.php

示例12: preSubmit

 /**
  * @param FormEvent $event
  */
 public function preSubmit(FormEvent $event)
 {
     $data = $event->getData();
     $form = $event->getForm();
     $country = array_key_exists('country', $data) ? $data['country'] : null;
     $this->addDiscretionarySpendingForm($form, $country);
 }
开发者ID:roberto-slopez,项目名称:CYA,代码行数:10,代码来源:AddDiscretionarySpendingFieldSubscriber.php

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

示例14: submit

 /**
  * Form event - removes file if scheduled.
  * 
  * @param FormEvent $event
  */
 public function submit(FormEvent $event)
 {
     $entity = $event->getData();
     if ($entity instanceof FileInterface && null === $entity->getId() && null === $entity->getHash()) {
         $event->setData(null);
     }
 }
开发者ID:thrace-project,项目名称:media-bundle,代码行数:12,代码来源:FileUploadSubscriber.php

示例15: manageExtraFiltersFields

 /**
  * @param FormEvent $event
  */
 public function manageExtraFiltersFields(FormEvent $event)
 {
     $data = $event->getData();
     $form = $event->getForm()->getParent();
     $form->remove('format');
     $form->remove('defaultValue');
     $eventDefaultValue = null;
     switch ($data) {
         case DateFilter::class:
             $form->remove('multiple');
             $form->add('format', ChoiceType::class, ['label' => 'widget_filter.form.date.format.label', 'choices' => ['widget_filter.form.date.format.choices.year.label' => 'year', 'widget_filter.form.date.format.choices.month.label' => 'month', 'widget_filter.form.date.format.choices.day.label' => 'day'], 'choices_as_values' => true, 'attr' => ['data-refreshOnChange' => 'true']]);
             $eventDefaultValue = 'victoire.widget_filter.form.date.set_default_value';
             break;
         case TagFilter::class:
             $form->add('multiple', null, ['label' => 'widget_filter.form.multiple.label']);
             $eventDefaultValue = 'victoire.widget_filter.form.tag.set_default_value';
             break;
         case CategoryFilter::class:
             $form->add('multiple', null, ['label' => 'widget_filter.form.multiple.label']);
             $eventDefaultValue = 'victoire.widget_filter.form.category.set_default_value';
             break;
     }
     if ($eventDefaultValue) {
         $defaultValueEvent = new WidgetFilterSetDefaultValueEvent($form, $data);
         $this->eventDispatcher->dispatch($eventDefaultValue, $defaultValueEvent);
     }
 }
开发者ID:victoire,项目名称:victoire,代码行数:30,代码来源:BlogFilterListener.php


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