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


PHP Form::getConfig方法代码示例

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


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

示例1: saveErrorsToFlashBag

 /**
  * @param Request $request
  * @param
  *            $form
  * @param
  *            $errors
  */
 protected function saveErrorsToFlashBag(Request $request, Form $form)
 {
     $formClass = get_class($form->getConfig()->getType()->getInnerType());
     $errors = [];
     foreach ($form->getErrors(TRUE) as $error) {
         $cause = $error->getCause();
         $errors[] = ['message' => $error->getMessage(), 'messageTemplate' => $error->getMessageTemplate(), 'messageParameters' => $error->getMessageParameters(), 'messagePluralization' => $error->getMessagePluralization(), 'cause' => preg_replace('/data\\.|children\\[(.*?)\\]/', '$1', $cause->getPropertyPath()), 'invalidValue' => $cause->getInvalidValue()];
     }
     $this->addFlash('validation_error_' . $formClass, $errors);
     $this->addFlash('validation_error_request_' . $formClass, $request);
 }
开发者ID:lobiferi,项目名称:TTWorkshop,代码行数:18,代码来源:TTControllerHelperTrait.php

示例2: getGroups

 /**
  * @param Form $form
  *
  * @return array
  */
 protected function getGroups($form)
 {
     $result = array();
     $result['groups'] = $form->getConfig()->getOption('validation_groups');
     $result['children'] = array();
     /** @var Form $element */
     foreach ($form->all() as $name => $element) {
         $result['children'][$name] = $this->getGroups($element);
     }
     return $result;
 }
开发者ID:eko,项目名称:JsFormValidatorBundle,代码行数:16,代码来源:BaseTestController.php

示例3: buildTypeSettingsForm

 /**
  * @param Form   $form         Main form.
  * @param string $providerName Provider.
  */
 protected function buildTypeSettingsForm(Form $form, $providerName)
 {
     // create sub-form wrapper
     $subForm = $form->getConfig()->getFormFactory()->createNamed('properties', 'form', null, array('label' => false, 'auto_initialize' => false));
     //Add provider form
     if ($providerName && isset($this->providers[$providerName])) {
         $provider = $this->providers[$providerName];
         // delegate form structure building for specific provider
         $provider->buildForm($subForm);
     }
     $form->add($subForm);
 }
开发者ID:aboutcoders,项目名称:file-distribution-bundle,代码行数:16,代码来源:FieldValueChangeSubscriber.php

示例4: addField

 public function addField(Form $form, $parser = null)
 {
     if ($parser === null) {
         return false;
     }
     $options = $form->getConfig()->getOptions();
     $em = $options['em'];
     if (!$parser instanceof Newscoop\IngestPluginBundle\Entity\Parser) {
         $parser = $em->getRepository('Newscoop\\IngestPluginBundle\\Entity\\Parser')->findOneById($parser);
     }
     if ($parser->requiresUrl()) {
         $form->add('url', 'url', array('label' => 'plugin.ingest.feeds.url', 'required' => true));
     }
 }
开发者ID:thnkloud9,项目名称:plugin-IngestPluginBundle,代码行数:14,代码来源:AddUrlFieldSubscriber.php

示例5: parseConstraints

 /**
  * Converts list of constraints objects to a data array
  *
  * @param array $constraints
  *
  * @return array
  */
 protected function parseConstraints(array $constraints)
 {
     $result = array();
     foreach ($constraints as $item) {
         // Translate messages if need and add to result
         foreach ($item as $propName => $propValue) {
             if (false !== strpos(strtolower($propName), 'message')) {
                 $item->{$propName} = $this->translateMessage($propValue);
             }
         }
         if ($item instanceof \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity) {
             $item = new UniqueEntity($item, $this->currentElement->getConfig()->getDataClass());
         }
         $result[get_class($item)][] = $item;
     }
     return $result;
 }
开发者ID:ruijl,项目名称:JsFormValidatorBundle,代码行数:24,代码来源:JsFormValidatorFactory.php

示例6: getRecursiveReadableErrors

 /**
  * Returns a string representation of all form errors (including children errors).
  *
  * This method should only be used in ajax calls.
  *
  * @param Form $form         The form to parse
  * @param bool $withChildren Do we parse the embedded forms
  *
  * @return string A string representation of all errors
  */
 public function getRecursiveReadableErrors($form, $withChildren = true, $translationDomain = null, $level = 0)
 {
     $errors = '';
     $translationDomain = $translationDomain ? $translationDomain : $form->getConfig()->getOption('translation_domain');
     //the errors of the fields
     foreach ($form->getErrors() as $error) {
         //the view contains the label identifier
         $view = $form->createView();
         $labelId = $view->vars['label'];
         //get the translated label
         if ($labelId !== null) {
             $label = $this->translator->trans($labelId, [], $translationDomain) . ' : ';
         } else {
             $label = '';
         }
         //in case of dev mode, we display the item that is a problem
         //getCause cames in Symfony 2.5 version, this is just a fallback to avoid BC with previous versions
         if ($this->debug && method_exists($error, 'getCause')) {
             $cause = $error->getCause();
             if ($cause !== null) {
                 $causePropertyPath = $cause->getPropertyPath();
                 $errors .= ' ' . $causePropertyPath;
             }
         }
         //add the error
         $errors .= $label . $this->translator->trans($error->getMessage(), [], $translationDomain) . "\n";
     }
     //do we parse the children
     if ($withChildren) {
         //we parse the children
         foreach ($form->getIterator() as $child) {
             $level++;
             if ($err = $this->getRecursiveReadableErrors($child, $withChildren, $translationDomain, $level)) {
                 $errors .= $err;
             }
         }
     }
     return $errors;
 }
开发者ID:victoire,项目名称:victoire,代码行数:49,代码来源:FormErrorHelper.php

示例7: getConditionBuilder

 /**
  * Get the conditon builder object for the given form.
  *
  * @param Form $form
  * @return ConditionBuilderInterface
  */
 protected function getConditionBuilder(Form $form)
 {
     $builderClosure = $form->getConfig()->getAttribute('filter_condition_builder');
     $builder = new ConditionBuilder();
     if ($builderClosure instanceof \Closure) {
         $builderClosure($builder);
     } else {
         $this->buildDefaultConditionNode($form, $builder->root('AND'));
     }
     return $builder;
 }
开发者ID:RMCProducciones,项目名称:CE,代码行数:17,代码来源:FilterBuilderUpdater.php

示例8: getSessionName

 private function getSessionName(Form $form)
 {
     return 'filter_form_' . $form->getConfig()->getName();
 }
开发者ID:alpixel,项目名称:AlpixelFormBundle,代码行数:4,代码来源:FormCookieSubscriber.php

示例9: load

 /**
  * @param Request $request
  * @param Form $form
  * @return $this
  */
 public function load(Request $request, Form $form)
 {
     $this->_load($request, $form->getConfig()->getMethod(), $form->getName());
     $form->handleRequest($request);
     return $this;
 }
开发者ID:wucdbm,项目名称:wucdbm-bundle,代码行数:11,代码来源:AbstractFilter.php

示例10: modelizeForm

 /**
  * @param Form   $form
  * @param array  $metadata
  * @param string $prefix
  *
  * @return array|string
  */
 protected function modelizeForm(Form $form, &$metadata, $prefix = null)
 {
     if ($form->getConfig()->getCompound()) {
         $all = $form->all();
         $model = [];
         foreach ($all as $formField) {
             /** @var Form $formField */
             $model[$formField->getName()] = $this->modelizeForm($formField, $metadata, null === $prefix ? '' : $prefix . ($prefix ? '.' : '') . $form->getName());
         }
         ksort($model);
         return $model;
     } else {
         $value = 'string';
         if ($form->getConfig()->getOption('choices')) {
             $value = array_keys($form->getConfig()->getOption('choices'));
             $metadata[$prefix . ($prefix ? '.' : '') . $form->getName()] = ['type' => lcfirst(preg_replace('/^api/', '', $form->getConfig()->getType()->getName())), 'constraints' => $this->buildConstraints($form) + [['type' => 'choices', 'vars' => ['values' => $value]]], 'default' => !is_object($form->getConfig()->getOption('empty_data')) ? $form->getConfig()->getOption('empty_data') : null];
         } elseif ($form->getConfig()->getOption('type')) {
             /** @var AbstractType $type */
             $type = $this->modelizeForm($form->getConfig()->getOption('type'), $metadata, ($prefix ? '.' : '') . $prefix);
             unset($type);
             $metadata[$prefix . ($prefix ? '.' : '') . $form->getName()] = ['type' => lcfirst(preg_replace('/^api/', '', $form->getConfig()->getType()->getName())), 'constraints' => $this->buildConstraints($form), 'default' => !is_object($form->getConfig()->getOption('empty_data')) ? $form->getConfig()->getOption('empty_data') : null];
             $value = [];
         } else {
             $metadata[$prefix . ($prefix ? '.' : '') . $form->getName()] = ['type' => lcfirst(preg_replace('/^api/', '', $form->getConfig()->getType()->getName())), 'constraints' => $this->buildConstraints($form), 'default' => !is_object($form->getConfig()->getOption('empty_data')) ? $form->getConfig()->getOption('empty_data') : null];
         }
         return $value;
     }
 }
开发者ID:phppro,项目名称:silex-api,代码行数:35,代码来源:RouteService.php

示例11: getCsrfToken

 /**
  * @param Form $form The form to inspect
  * @return string The resulting CSRF token
  */
 private function getCsrfToken(Form $form)
 {
     /** @var \Symfony\Component\Form\FormConfigInterface $c */
     $c = $form->getConfig();
     /** @var \Symfony\Component\Security\CSRF\CsrfTokenManager $tokMgr */
     $tokMgr = $c->getOption("csrf_token_manager");
     /** @var \Symfony\Component\Security\CSRF\CsrfToken $csrf_token */
     $token = $tokMgr->getToken('form');
     return $token->getValue();
 }
开发者ID:ruderphilipp,项目名称:regatta,代码行数:14,代码来源:RegistrationController.php

示例12: getFormat

 /**
  * @param Form $item
  * @param array $validationOutput
  * @param $camelCasedKey
  *
  * @return null|string
  */
 private function getFormat(Form $item, array $validationOutput, $camelCasedKey)
 {
     $type = $item->getConfig()->getType()->getInnerType();
     if (BooleanType::class === $type) {
         return '[false|true|0|1]';
     }
     return isset($validationOutput[$camelCasedKey]['format']) ? $validationOutput[$camelCasedKey]['format'] : null;
 }
开发者ID:Eraac,项目名称:rest-project,代码行数:15,代码来源:Parser.php


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