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


PHP Form\FormInterface类代码示例

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


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

示例1: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $data = $form->getData();
     if (empty($data)) {
         $form->setData(array('left' => 0, 'top' => 0, 'width' => $options['width'], 'height' => $options['height'], 'min_width' => $options['width'], 'min_height' => $options['height']));
     }
 }
开发者ID:it-blaster,项目名称:crop-bundle,代码行数:10,代码来源:CropInstanceType.php

示例2:

 function it_builds_view(FormConfigInterface $config, FormView $view, FormInterface $form, FormInterface $prototype)
 {
     $form->getConfig()->willReturn($config);
     $config->getAttribute('prototypes')->willReturn(['configuration_kind' => $prototype]);
     $prototype->createView($view)->shouldBeCalled();
     $this->buildView($view, $form, []);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:7,代码来源:PromotionActionCollectionTypeSpec.php

示例3: process

 /**
  * @param FormInterface $form
  * @param Request $request
  * @return AccountUser|bool
  */
 public function process(FormInterface $form, Request $request)
 {
     if ($request->isMethod('POST')) {
         $form->submit($request);
         if ($form->isValid()) {
             $email = $form->get('email')->getData();
             /** @var AccountUser $user */
             $user = $this->userManager->findUserByUsernameOrEmail($email);
             if ($this->validateUser($form, $email, $user)) {
                 if (null === $user->getConfirmationToken()) {
                     $user->setConfirmationToken($user->generateToken());
                 }
                 try {
                     $this->userManager->sendResetPasswordEmail($user);
                     $user->setPasswordRequestedAt(new \DateTime('now', new \DateTimeZone('UTC')));
                     $this->userManager->updateUser($user);
                     return $user;
                 } catch (\Exception $e) {
                     $this->addFormError($form, 'oro.email.handler.unable_to_send_email');
                 }
             }
         }
     }
     return false;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:30,代码来源:AccountUserPasswordRequestHandler.php

示例4: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->vars['feeCalculatorsConfigurations'] = array();
     foreach ($form->getConfig()->getAttribute('feeCalculatorsConfigurations') as $type => $feeCalculatorConfiguration) {
         $view->vars['feeCalculatorsConfigurations'][$type] = $feeCalculatorConfiguration->createView($view);
     }
 }
开发者ID:nanyi,项目名称:Sylius,代码行数:10,代码来源:PaymentMethodType.php

示例5: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if ($form->getData() instanceof ProductValueInterface) {
         $this->productFormView->addChildren($form->getData(), $view);
     }
     $view->vars['mode'] = isset($options['block_config']['mode']) ? $options['block_config']['mode'] : 'normal';
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:10,代码来源:ProductValueType.php

示例6: chooseGroups

 /**
  * {@inheritdoc}
  */
 public function chooseGroups(FormInterface $form)
 {
     $dayPhoneData = $form->get('dayPhone')->getData();
     $eveningPhoneData = $form->get('eveningPhone')->getData();
     $emailData = $form->get('email')->getData();
     // All other fields are validated through the Default validation group
     $validation_groups = array('Default');
     // todo: is there an apprpoach that does not require the sdk models?
     /** @var ReferencingApplication $application */
     $application = $form->getParent()->getData();
     if ($application instanceof ReferencingApplication) {
         // If Optimum product, require at least one contact detail must be given
         if (19 == $application->getProductId()) {
             if (empty($dayPhoneData) && empty($eveningPhoneData) && empty($emailData)) {
                 $validation_groups[] = 'dayphone';
                 $validation_groups[] = 'eveningphone';
                 $validation_groups[] = 'email';
             }
         }
         // If no day phone, enforce evening
         if (empty($dayPhoneData)) {
             $validation_groups[] = 'eveningphone';
         }
         // If no evening phone, enforce day
         if (empty($eveningPhoneData)) {
             if ($k = array_search('eveningphone', $validation_groups)) {
                 unset($validation_groups[$k]);
             }
             $validation_groups[] = 'dayphone';
         }
         return $validation_groups;
     }
     return array('Default');
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:37,代码来源:LettingRefereeValidationGroupSelector.php

示例7: buildView

 /**
  * @param \Symfony\Component\Form\FormView $view
  * @param \Symfony\Component\Form\FormInterface $form
  */
 public function buildView(FormView $view, FormInterface $form)
 {
     $sonataAdmin = $form->getAttribute('sonata_admin');
     // avoid to add extra information not required by non admin field
     if ($form->getAttribute('sonata_admin_enabled', true)) {
         $sonataAdmin['value'] = $form->getData();
         // add a new block types, so the Admin Form element can be tweaked based on the admin code
         $types = $view->get('types');
         $baseName = str_replace('.', '_', $sonataAdmin['field_description']->getAdmin()->getCode());
         $baseType = $types[count($types) - 1];
         $types[] = sprintf('%s_%s', $baseName, $baseType);
         $types[] = sprintf('%s_%s_%s', $baseName, $sonataAdmin['field_description']->getName(), $baseType);
         if ($sonataAdmin['block_name']) {
             $types[] = $sonataAdmin['block_name'];
         }
         $view->set('types', $types);
         $view->set('sonata_admin_enabled', true);
         $view->set('sonata_admin', $sonataAdmin);
         $attr = $view->get('attr', array());
         if (!isset($attr['class'])) {
             $attr['class'] = $sonataAdmin['class'];
         }
         $view->set('attr', $attr);
     } else {
         $view->set('sonata_admin_enabled', false);
     }
     $view->set('sonata_admin', $sonataAdmin);
 }
开发者ID:nzzdev,项目名称:SonataAdminBundle,代码行数:32,代码来源:FormTypeFieldExtension.php

示例8: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $value = $form->getViewData();
     // set string representation
     if (true === $value) {
         $value = 'true';
     } elseif (false === $value) {
         $value = 'false';
     } elseif (null === $value) {
         $value = 'null';
     } elseif (is_array($value)) {
         $value = implode(', ', $value);
     } elseif ($value instanceof \DateTime) {
         $dateFormat = is_int($options['date_format']) ? $options['date_format'] : DateType::DEFAULT_FORMAT;
         $timeFormat = is_int($options['time_format']) ? $options['time_format'] : DateType::DEFAULT_FORMAT;
         $calendar = \IntlDateFormatter::GREGORIAN;
         $pattern = is_string($options['date_pattern']) ? $options['date_pattern'] : null;
         $formatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormat, $timeFormat, 'UTC', $calendar, $pattern);
         $formatter->setLenient(false);
         $value = $formatter->format($value);
     } elseif (is_object($value)) {
         if (method_exists($value, '__toString')) {
             $value = $value->__toString();
         } else {
             $value = get_class($value);
         }
     }
     $view->vars['value'] = (string) $value;
 }
开发者ID:GeneralMediaCH,项目名称:GenemuFormBundle,代码行数:32,代码来源:PlainType.php

示例9: getRootFormCascadeOption

 /**
  * Navigates to the Root form to define if cascading should be done.
  *
  * @param FormInterface $form
  * @return boolean
  */
 public function getRootFormCascadeOption(FormInterface $form)
 {
     if (!$form->isRoot()) {
         return $this->getRootFormCascadeOption($form->getParent());
     }
     return $form->getConfig()->getOption('cascade_filter', false);
 }
开发者ID:rdohms,项目名称:dms-filter-bundle,代码行数:13,代码来源:DelegatingFilterListener.php

示例10: process

 /**
  * {@inheritdoc}
  */
 public function process(FormInterface $form, Request $request)
 {
     $valid = false;
     if ($request->isMethod('POST')) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $transUnit = $form->getData();
             $translations = $transUnit->filterNotBlankTranslations();
             // only keep translations with a content
             // link new translations to a file to be able to export them.
             foreach ($translations as $translation) {
                 if (!$translation->getFile()) {
                     $file = $this->fileManager->getFor(sprintf('%s.%s.yml', $transUnit->getDomain(), $translation->getLocale()), $this->rootDir . '/Resources/translations');
                     if ($file instanceof FileInterface) {
                         $translation->setFile($file);
                     }
                 }
             }
             if ($transUnit instanceof PropelTransUnit) {
                 // The setTranslations() method only accepts PropelCollections
                 $translations = new \PropelObjectCollection($translations);
             }
             $transUnit->setTranslations($translations);
             $this->storage->persist($transUnit);
             $this->storage->flush();
             $valid = true;
         }
     }
     return $valid;
 }
开发者ID:cybermo,项目名称:LexikTranslationBundle,代码行数:33,代码来源:TransUnitFormHandler.php

示例11: buildView

 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     //parent::buildView($view, $form, $options);
     $entity = $form->getParent()->getData();
     $property_name = $view->vars['name'];
     $this->defaults = array_merge($this->defaults, $options);
     // entity info
     $entity_info = $this->container->get('itf.admin_helper')->getEntityInfo(get_class($entity));
     $fk_entity_info = $this->container->get('itf.admin_helper')->getEntityInfo($this->defaults['data_class']);
     $this->defaults['fn_entity'] = $entity_info['entity_short'];
     $this->defaults['fn_bundle'] = $entity_info['bundle_short'];
     $this->defaults['fn_property'] = $property_name;
     $this->defaults['fn_fk_entity'] = $fk_entity_info['entity_short'];
     $this->defaults['fn_fk_bundle'] = $fk_entity_info['bundle_short'];
     // extract constraints
     $validator = $this->container->get('validator');
     $metadata = $validator->getMetadataFor($fk_entity_info['entity_fq']);
     if (isset($metadata->properties[$this->defaults['fn_entity_property']])) {
         $this->extractConstraints($metadata->properties[$this->defaults['fn_entity_property']]);
     }
     // set id
     if (method_exists($entity, 'getId')) {
         $this->defaults['fn_entity_id'] = (int) $entity->getId();
     }
     $view->vars = array_merge($view->vars, $this->defaults);
 }
开发者ID:RSSfeed,项目名称:AdminBundle,代码行数:26,代码来源:FineuploaderMultipleType.php

示例12: addConfigurationFields

 /**
  * @param FormInterface $form
  * @param string        $ruleType
  * @param array         $data
  */
 protected function addConfigurationFields(FormInterface $form, $ruleType, array $data = [])
 {
     /** @var RuleCheckerInterface $checker */
     $checker = $this->checkerRegistry->get($ruleType);
     $configurationField = $this->factory->createNamed('configuration', $checker->getConfigurationFormType(), $data, ['auto_initialize' => false]);
     $form->add($configurationField);
 }
开发者ID:TeamNovatek,项目名称:Sylius,代码行数:12,代码来源:BuildRuleFormSubscriber.php

示例13:

 function it_builds_view(FormView $view, FormInterface $form, FormConfigInterface $formConfig)
 {
     $form->getConfig()->shouldBeCalled()->willReturn($formConfig);
     $formConfig->getAttribute('prototypes')->shouldBeCalled()->willReturn(['type' => $form]);
     $form->createView($view)->shouldBeCalled();
     $this->buildView($view, $form, []);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:7,代码来源:PriceableTypeExtensionSpec.php

示例14: formatFormErrors

 /**
  * @param FormInterface     $form
  * @param array             $results
  *
  * @return array
  */
 private function formatFormErrors(FormInterface $form, &$results = array())
 {
     /*
      * first check if there are any errors bound for this element
      */
     $errors = $form->getErrors();
     if (count($errors)) {
         $messages = [];
         foreach ($errors as $error) {
             if ($error instanceof FormError) {
                 $messages[] = $this->translator->trans($error->getMessage(), $error->getMessageParameters(), 'validators');
             }
             $results[] = ['property_path' => $this->formatPropertyPath($error), 'message' => join(', ', $messages)];
         }
     }
     /*
      * Then, check if there are any children. If yes, then parse them
      */
     $children = $form->all();
     if (count($children)) {
         foreach ($children as $child) {
             if ($child instanceof FormInterface) {
                 $this->formatFormErrors($child, $results);
             }
         }
     }
     return $results;
 }
开发者ID:nass59,项目名称:Lab,代码行数:34,代码来源:PaginatedViewHandler.php

示例15: buildView

 /**
  * @param \Symfony\Component\Form\FormView $view
  * @param \Symfony\Component\Form\FormInterface $form
  * @param array $options
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if ($options['reload'] && !$options['as_url']) {
         throw new \InvalidArgumentException('GregwarCaptcha: The reload option cannot be set without as_url, see the README for more information');
     }
     $sessionKey = sprintf('gcb_%s', $form->getName());
     $isHuman = false;
     if ($options['humanity'] > 0) {
         $humanityKey = sprintf('%s_humanity', $sessionKey);
         if ($this->session->get($humanityKey, 0) > 0) {
             $isHuman = true;
         }
     }
     if ($options['as_url']) {
         $keys = $this->session->get($options['whitelist_key'], array());
         if (!in_array($sessionKey, $keys)) {
             $keys[] = $sessionKey;
         }
         $this->session->set($options['whitelist_key'], $keys);
         $options['session_key'] = $sessionKey;
     }
     $view->vars = array_merge($view->vars, array('captcha_width' => $options['width'], 'captcha_height' => $options['height'], 'reload' => $options['reload'], 'image_id' => uniqid('captcha_'), 'captcha_code' => $this->generator->getCaptchaCode($options), 'value' => '', 'is_human' => $isHuman));
     $persistOptions = array();
     foreach (array('phrase', 'width', 'height', 'distortion', 'length', 'quality', 'background_color', 'text_color') as $key) {
         $persistOptions[$key] = $options[$key];
     }
     $this->session->set($sessionKey, $persistOptions);
 }
开发者ID:BaudouinW,项目名称:Aion-Rising-Back-end,代码行数:33,代码来源:CaptchaType.php


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