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


PHP Form\FormEvent类代码示例

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


在下文中一共展示了FormEvent类的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: 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: 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: 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

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

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

示例7:

 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

示例8: preSubmit

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

示例9: preSetData

 /**
  * PRE_SET_DATA event handler
  *
  * @param FormEvent $event
  */
 public function preSetData(FormEvent $event)
 {
     $form = $event->getForm();
     if ($this->calendarConfig->isPublicCalendarEnabled() && $this->calendarConfig->isSystemCalendarEnabled()) {
         $options = ['required' => false, 'label' => 'oro.calendar.systemcalendar.public.label', 'empty_value' => false, 'choices' => [false => 'oro.calendar.systemcalendar.scope.organization', true => 'oro.calendar.systemcalendar.scope.system']];
         /** @var SystemCalendar|null $data */
         $data = $event->getData();
         if ($data) {
             $isPublicGranted = $this->securityFacade->isGranted('oro_public_calendar_management');
             $isSystemGranted = $this->securityFacade->isGranted($data->getId() ? 'oro_system_calendar_update' : 'oro_system_calendar_create');
             if (!$isPublicGranted || !$isSystemGranted) {
                 $options['read_only'] = true;
                 if (!$data->getId() && !$isSystemGranted) {
                     $options['data'] = true;
                 }
                 unset($options['choices'][$isSystemGranted]);
             }
         }
         $form->add('public', 'choice', $options);
     } elseif ($this->calendarConfig->isPublicCalendarEnabled()) {
         $form->add('public', 'hidden', ['data' => true]);
     } elseif ($this->calendarConfig->isSystemCalendarEnabled()) {
         $form->add('public', 'hidden', ['data' => false]);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:30,代码来源:SystemCalendarType.php

示例10: postBind

 /**
  * @param FormEvent $event
  */
 public function postBind(FormEvent $event)
 {
     $product = $event->getData();
     $thumbnail = '';
     $first = false;
     foreach ($product->getImages() as $image) {
         if (!$first) {
             $thumbnail = $image->getPath();
             $first = true;
         }
         if ($image->getThumb()) {
             $thumbnail = $image->getPath();
         }
         $image->setProduct($product);
         $this->container->get('product_manager')->save($image, false);
     }
     $product->setThumbnail($thumbnail);
     if (null !== $product->getId()) {
         $imageDir = $this->container->get('kernel')->getRootDir() . '/../web/uploads/products/';
         $imgList = $this->container->get('product_image_manager')->getRepository()->findBy(array('product' => $product->getId()));
         foreach ($imgList as $image) {
             if (!$product->getImages()->contains($image)) {
                 if (file_exists($imageDir . $image->getPath())) {
                     unlink($imageDir . $image->getPath());
                 }
                 $this->container->get('product_manager')->delete($image);
             }
         }
     }
 }
开发者ID:rarekit,项目名称:posit,代码行数:33,代码来源:ProductSubscriber.php

示例11: addFormType

 /**
  * @param FormEvent $event
  */
 protected function addFormType(FormEvent $event)
 {
     $form = $event->getForm();
     $data = $event->getData();
     $event->setData($data);
     if ($form->has('contentId')) {
         $form->remove('contentId');
     }
     if ($form->has('help-text')) {
         $form->remove('help-text');
     }
     $choices = array();
     if (!is_null($data)) {
         if (array_key_exists('contentType', $data) && $data['contentType'] != '') {
             $choices = array_merge($choices, $this->getChoices($data['contentType'], array_key_exists('choiceType', $data) && $data['choiceType'] != '' ? $data['choiceType'] : ReadContentRepositoryInterface::CHOICE_AND, array_key_exists('keywords', $data) && $data['keywords'] ? $data['keywords'] : null));
         }
         if (array_key_exists('contentId', $data) && $data['contentId'] != '') {
             $choices = array_merge($choices, $this->getChoice($data['contentId']));
         }
     }
     if (count($choices) > 0) {
         $form->add('contentId', 'choice', array('label' => false, 'empty_value' => ' ', 'required' => $this->required, 'choices' => $choices, 'attr' => $this->attributes));
     } else {
         $form->add('contentId', 'hidden', array('required' => $this->required, 'error_mapping' => 'help-text'));
         $form->add('help-text', 'button', array('disabled' => true, 'label' => 'open_orchestra_backoffice.form.content_search.use'));
     }
 }
开发者ID:open-orchestra,项目名称:open-orchestra-cms-bundle,代码行数:30,代码来源:ContentSearchSubscriber.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: preBind

 public function preBind(FormEvent $event)
 {
     $value = $event->getData();
     if (is_array($value)) {
         $event->setData(implode($this->delimiter, $value));
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:7,代码来源:FixArrayToStringListener.php

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

示例15: onPreSetData

 public function onPreSetData(FormEvent $event)
 {
     $form = $event->getForm();
     if (!is_object($this->user) || !$this->user instanceof UserInterface) {
         $form->add('guest', new GuestType());
     }
 }
开发者ID:GautierKris,项目名称:Snoozit,代码行数:7,代码来源:AdvertType.php


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