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


PHP FormInterface::getConfig方法代码示例

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


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

示例1:

 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

示例2: buildView

 /**
  * @param FormView      $view
  * @param FormInterface $form
  * @param array         $options
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $sonataAdmin = $form->getConfig()->getAttribute('sonata_admin');
     // avoid to add extra information not required by non admin field
     if ($form->getConfig()->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->vars['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->vars['types'] = $types;
         $view->vars['sonata_admin_enabled'] = true;
         $view->vars['sonata_admin'] = $sonataAdmin;
         $attr = $view->vars['attr'];
         if (!isset($attr['class'])) {
             $attr['class'] = $sonataAdmin['class'];
         }
         $view->vars['attr'] = $attr;
     } else {
         $view->vars['sonata_admin_enabled'] = false;
     }
     $view->vars['sonata_admin'] = $sonataAdmin;
 }
开发者ID:natxet,项目名称:SonataAdminBundle,代码行数:33,代码来源:FormTypeFieldExtension.php

示例3: handleRequest

 /**
  * {@inheritdoc}
  */
 public function handleRequest(FormInterface $form, $request = null)
 {
     if (null !== $request) {
         throw new UnexpectedTypeException($request, 'null');
     }
     $name = $form->getName();
     $method = $form->getConfig()->getMethod();
     if ($method !== self::getRequestMethod()) {
         return;
     }
     // For request methods that must not have a request body we fetch data
     // from the query string. Otherwise we look for data in the request body.
     if ('GET' === $method || 'HEAD' === $method || 'TRACE' === $method) {
         if ('' === $name) {
             $data = $_GET;
         } else {
             // Don't submit GET requests if the form's name does not exist
             // in the request
             if (!isset($_GET[$name])) {
                 return;
             }
             $data = $_GET[$name];
         }
     } else {
         // Mark the form with an error if the uploaded size was too large
         // This is done here and not in FormValidator because $_POST is
         // empty when that error occurs. Hence the form is never submitted.
         if ($this->serverParams->hasPostMaxSizeBeenExceeded()) {
             // Submit the form, but don't clear the default values
             $form->submit(null, false);
             $form->addError(new FormError($form->getConfig()->getOption('post_max_size_message'), null, array('{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize())));
             return;
         }
         $fixedFiles = array();
         foreach ($_FILES as $fileKey => $file) {
             $fixedFiles[$fileKey] = self::stripEmptyFiles(self::fixPhpFilesArray($file));
         }
         if ('' === $name) {
             $params = $_POST;
             $files = $fixedFiles;
         } elseif (array_key_exists($name, $_POST) || array_key_exists($name, $fixedFiles)) {
             $default = $form->getConfig()->getCompound() ? array() : null;
             $params = array_key_exists($name, $_POST) ? $_POST[$name] : $default;
             $files = array_key_exists($name, $fixedFiles) ? $fixedFiles[$name] : $default;
         } else {
             // Don't submit the form if it is not present in the request
             return;
         }
         if (is_array($params) && is_array($files)) {
             $data = array_replace_recursive($params, $files);
         } else {
             $data = $params ?: $files;
         }
     }
     // Don't auto-submit the form unless at least one field is present.
     if ('' === $name && count(array_intersect_key($data, $form->all())) <= 0) {
         return;
     }
     $form->submit($data, 'PATCH' !== $method);
 }
开发者ID:unexge,项目名称:symfony,代码行数:63,代码来源:NativeRequestHandler.php

示例4: buildView

 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->vars['parent_field'] = $form->getConfig()->getAttribute('parent_field');
     $view->vars['entity_alias'] = $form->getConfig()->getAttribute('entity_alias');
     $view->vars['no_result_msg'] = $form->getConfig()->getAttribute('no_result_msg');
     $view->vars['empty_value'] = $form->getConfig()->getAttribute('empty_value');
 }
开发者ID:reiarseni,项目名称:ShtumiUsefulBundle,代码行数:7,代码来源:DependentFilteredSelect2Type.php

示例5: transform

 public function transform(FormInterface $form, $extensions = [])
 {
     $data = [];
     $order = 1;
     $required = [];
     foreach ($form->all() as $name => $field) {
         $transformedChild = $this->resolver->resolve($field)->transform($field, $extensions);
         $transformedChild['propertyOrder'] = $order;
         $data[$name] = $transformedChild;
         $order++;
         if ($this->resolver->resolve($field)->isRequired($field)) {
             $required[] = $field->getName();
         }
     }
     $schema = ['title' => $form->getConfig()->getOption('label'), 'type' => 'object', 'properties' => $data];
     if (!empty($required)) {
         $schema['required'] = $required;
     }
     $innerType = $form->getConfig()->getType()->getInnerType();
     if (method_exists($innerType, 'buildLiform')) {
         $schema['liform'] = $innerType->buildLiform($form);
     }
     $this->addCommonSpecs($form, $schema, $extensions);
     return $schema;
 }
开发者ID:limenius,项目名称:liform,代码行数:25,代码来源:CompoundTransformer.php

示例6: finishView

 /**
  * {@inheritdoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     if ($form->getConfig()->hasAttribute('prototype') && $view->vars['prototype']->vars['multipart']) {
         $view->vars['multipart'] = true;
     }
     $options = $form->getConfig()->getOptions();
     $view->vars['null_locale_enabled'] = $options['null_locale_enabled'];
     $view->vars['null_locale_selected'] = $options['null_locale_selected'];
     $requestLocale = $this->getRequestLocale();
     $view->vars['locale_titles'] = array();
     foreach ($options['locales'] as $locale) {
         $view->vars['locale_titles'][$locale] = \Locale::getDisplayName($locale, $requestLocale);
     }
     $request = $this->getRequest();
     if (null === $request) {
         $current_selected_lang = $options['locales'][0];
     } else {
         $current_selected_lang = $request->cookies->get('current_selected_translation_lang', null);
         $selectedLanguageIsNotValid = $current_selected_lang !== '__all__' && !in_array($current_selected_lang, $options['locales']);
         if ($current_selected_lang === null || $selectedLanguageIsNotValid) {
             $current_selected_lang = $options['locales'][0];
         }
     }
     $view->vars['current_selected_lang'] = $current_selected_lang;
 }
开发者ID:nercury,项目名称:translation-editor-bundle,代码行数:28,代码来源:TranslationsEditorType.php

示例7: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $name = $form->getName();
     $blockName = $options['block_name'] ?: $form->getName();
     $translationDomain = $options['translation_domain'];
     if ($view->parent) {
         if ('' !== ($parentFullName = $view->parent->vars['full_name'])) {
             $id = sprintf('%s_%s', $view->parent->vars['id'], $name);
             $fullName = sprintf('%s[%s]', $parentFullName, $name);
             $uniqueBlockPrefix = sprintf('%s_%s', $view->parent->vars['unique_block_prefix'], $blockName);
         } else {
             $id = $name;
             $fullName = $name;
             $uniqueBlockPrefix = '_' . $blockName;
         }
         if (null === $translationDomain) {
             $translationDomain = $view->parent->vars['translation_domain'];
         }
     } else {
         $id = $name;
         $fullName = $name;
         $uniqueBlockPrefix = '_' . $blockName;
         // Strip leading underscores and digits. These are allowed in
         // form names, but not in HTML4 ID attributes.
         // http://www.w3.org/TR/html401/struct/global.html#adef-id
         $id = ltrim($id, '_0123456789');
     }
     $blockPrefixes = array();
     for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) {
         array_unshift($blockPrefixes, $type->getName());
     }
     $blockPrefixes[] = $uniqueBlockPrefix;
     $view->vars = array_replace($view->vars, array('form' => $view, 'id' => $id, 'name' => $name, 'full_name' => $fullName, 'disabled' => $form->isDisabled(), 'label' => $options['label'], 'multipart' => false, 'attr' => $options['attr'], 'block_prefixes' => $blockPrefixes, 'unique_block_prefix' => $uniqueBlockPrefix, 'translation_domain' => $translationDomain, 'cache_key' => $uniqueBlockPrefix . '_' . $form->getConfig()->getType()->getName()));
 }
开发者ID:mm999,项目名称:EduSoho,代码行数:37,代码来源:BaseType.php

示例8: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->vars['root_node'] = $form->getConfig()->getAttribute('root_node');
     $view->vars['select_root_node'] = $form->getConfig()->getAttribute('select_root_node');
     $view->vars['repository_name'] = $form->getConfig()->getAttribute('repository_name');
     $view->vars['routing_defaults'] = $this->defaults;
 }
开发者ID:jmontoyaa,项目名称:SonataDoctrinePhpcrAdminBundle,代码行数:10,代码来源:TreeModelType.php

示例9: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if ($form->getConfig()->hasAttribute('prototypes')) {
         $view->vars['prototypes'] = array_map(function (FormInterface $prototype) use($view) {
             return $prototype->createView($view);
         }, $form->getConfig()->getAttribute('prototypes'));
     }
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:11,代码来源:ZoneMemberCollectionType.php

示例10: buildView

 /**
  * @inheritdoc
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->vars['enable'] = $form->getConfig()->getAttribute('enable');
     if ($form->getConfig()->getAttribute('enable')) {
         $view->vars['instance'] = $form->getConfig()->getAttribute('instance');
         $view->vars['homeFolder'] = $form->getConfig()->getAttribute('homeFolder');
     }
 }
开发者ID:bonswouar,项目名称:FMElfinderBundle,代码行数:11,代码来源:ElFinderType.php

示例11: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $view->vars['visible'] = $form->getConfig()->getOption('visible');
     $displayText = $form->getConfig()->getOption('display_text');
     if ($view->vars['visible'] && is_callable($displayText)) {
         $view->vars['attr']['data-display-text'] = call_user_func($displayText, $form);
     }
 }
开发者ID:shtumi,项目名称:forms-extra-bundle,代码行数:11,代码来源:HiddenEntityType.php

示例12: handleRequest

 /**
  * {@inheritdoc}
  */
 public function handleRequest(FormInterface $form, $request = null)
 {
     if (!$request instanceof Request) {
         throw new UnexpectedTypeException($request, 'Symfony\\Component\\HttpFoundation\\Request');
     }
     $name = $form->getName();
     $method = $form->getConfig()->getMethod();
     if ($method !== $request->getMethod()) {
         return;
     }
     // For request methods that must not have a request body we fetch data
     // from the query string. Otherwise we look for data in the request body.
     if ('GET' === $method || 'HEAD' === $method || 'TRACE' === $method) {
         if ('' === $name) {
             $data = $request->query->all();
         } else {
             // Don't submit GET requests if the form's name does not exist
             // in the request
             if (!$request->query->has($name)) {
                 return;
             }
             $data = $request->query->get($name);
         }
     } else {
         // Mark the form with an error if the uploaded size was too large
         // This is done here and not in FormValidator because $_POST is
         // empty when that error occurs. Hence the form is never submitted.
         $contentLength = $this->serverParams->getContentLength();
         $maxContentLength = $this->serverParams->getPostMaxSize();
         if (!empty($maxContentLength) && $contentLength > $maxContentLength) {
             // Submit the form, but don't clear the default values
             $form->submit(null, false);
             $form->addError(new FormError($form->getConfig()->getOption('post_max_size_message'), null, array('{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize())));
             return;
         }
         if ('' === $name) {
             $params = $request->request->all();
             $files = $request->files->all();
         } elseif ($request->request->has($name) || $request->files->has($name)) {
             $default = $form->getConfig()->getCompound() ? array() : null;
             $params = $request->request->get($name, $default);
             $files = $request->files->get($name, $default);
         } else {
             // Don't submit the form if it is not present in the request
             return;
         }
         if (is_array($params) && is_array($files)) {
             $data = array_replace_recursive($params, $files);
         } else {
             $data = $params ?: $files;
         }
     }
     // Don't auto-submit the form unless at least one field is present.
     if ('' === $name && count(array_intersect_key($data, $form->all())) <= 0) {
         return;
     }
     $form->submit($data, 'PATCH' !== $method);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:61,代码来源:HttpFoundationRequestHandler.php

示例13: testFormCreate

 /**
  * Test build of form with form type
  */
 public function testFormCreate()
 {
     // Assert fields
     $this->assertField('label', 'pim_translatable_field');
     $this->assertField('sort_order', 'hidden');
     // Assert option class
     $this->assertEquals('Pim\\Bundle\\CatalogBundle\\Entity\\AttributeGroup', $this->form->getConfig()->getDataClass());
     // Assert name
     $this->assertEquals('pim_enrich_attribute_group', $this->form->getName());
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:13,代码来源:AttributeGroupTypeTest.php

示例14: isFormFieldSupported

 /**
  * @param FormInterface $field
  *
  * @return bool
  */
 private function isFormFieldSupported(FormInterface $field)
 {
     if ($field->getConfig()->getCompound()) {
         if ($field->getConfig()->getType()->getInnerType() instanceof RepeatedType) {
             return true;
         }
         return false;
     }
     return true;
 }
开发者ID:bangpound,项目名称:symfony-console-form,代码行数:15,代码来源:FormBasedInputDefinitionFactory.php

示例15: finishView

 /**
  * Adds a CSRF field to the root form view.
  *
  * @param FormView      $view    The form view
  * @param FormInterface $form    The form
  * @param array         $options The options
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     if ($options['csrf_protection'] && !$view->parent && $options['compound']) {
         $factory = $form->getConfig()->getAttribute('csrf_factory');
         $intention = $options['intention'] ?: ($form->getName() ?: get_class($form->getConfig()->getType()->getInnerType()));
         $data = $options['csrf_provider']->generateCsrfToken($intention);
         $csrfForm = $factory->createNamed($options['csrf_field_name'], 'hidden', $data, array('mapped' => false));
         $view->children[$options['csrf_field_name']] = $csrfForm->createView($view);
     }
 }
开发者ID:senthil-r-wiredelta,项目名称:meilleure-visite,代码行数:17,代码来源:FormTypeCsrfExtension.php


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