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


PHP FormInterface::all方法代码示例

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


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

示例1: serializeForm

 private function serializeForm(FormInterface $form)
 {
     if (!$form->all()) {
         return $form->getViewData();
     }
     $data = null;
     foreach ($form->all() as $child) {
         $name = $child->getConfig()->getName();
         $data[$name] = $this->serializeForm($child);
     }
     return $data;
 }
开发者ID:enhavo,项目名称:enhavo,代码行数:12,代码来源:FormSerializer.php

示例2: testSubmit

 /**
  * @dataProvider getValidInputs
  */
 public function testSubmit($submitted, $expected)
 {
     $this->sut->submit($submitted);
     $msg = '';
     if (!$this->sut->isValid()) {
         $msg = print_r($this->sut->getErrors(), true);
         foreach ($this->sut->all() as $child) {
             $msg .= "\n" . print_r($child->getErrors(), true);
         }
     }
     $this->assertTrue($this->sut->isValid(), $msg);
     $this->assertEquals($expected, $this->sut->getData());
 }
开发者ID:xtrasmal,项目名称:iinano,代码行数:16,代码来源:PublishingTestCase.php

示例3: interactWith

 public function interactWith(FormInterface $form, HelperSet $helperSet, InputInterface $input, OutputInterface $output)
 {
     if (!$form->isRoot()) {
         throw new CanNotInteractWithForm('This interactor only works with root forms');
     }
     if ($input->isInteractive()) {
         throw new CanNotInteractWithForm('This interactor only works with non-interactive input');
     }
     /*
      * We need to adjust the input values for repeated types by copying the provided value to both of the repeated
      * fields. We only loop through the top-level fields, since there are no command options for deeper lying fields
      * anyway.
      *
      * The fix was provided by @craigh
      *
      * P.S. If we need to add another fix like this, we should move this out to dedicated "input fixer" classes.
      */
     foreach ($form->all() as $child) {
         $config = $child->getConfig();
         $name = $child->getName();
         if ($config->getType()->getInnerType() instanceof RepeatedType && $input->hasOption($name)) {
             $input->setOption($name, [$config->getOption('first_name') => $input->getOption($name), $config->getOption('second_name') => $input->getOption($name)]);
         }
     }
     // use the original input as the submitted data
     return $input;
 }
开发者ID:stof,项目名称:symfony-console-form,代码行数:27,代码来源:NonInteractiveRootInteractor.php

示例4: mergeConstraints

 /**
  * Merges constraints from the form with constraints in the class metaData
  *
  * @param FormInterface $form
  */
 public function mergeConstraints(FormInterface &$form)
 {
     $metaData = null;
     $dataClass = $form->getConfig()->getDataClass();
     if ($dataClass != '') {
         $metaData = $this->validator->getMetadataFor($dataClass);
     }
     if ($metaData instanceof ClassMetadata) {
         /**
          * @var FormInterface $child
          */
         foreach ($form->all() as $child) {
             $options = $child->getConfig()->getOptions();
             $name = $child->getConfig()->getName();
             $type = $child->getConfig()->getType()->getName();
             if (isset($options['constraints'])) {
                 $existingConstraints = $options['constraints'];
                 $extractedConstraints = $this->extractPropertyConstraints($name, $metaData);
                 // Merge all constraints
                 $options['constraints'] = array_merge($existingConstraints, $extractedConstraints);
             }
             $form->add($name, $type, $options);
         }
     }
 }
开发者ID:josephjbrewer,项目名称:form-utils,代码行数:30,代码来源:MetaDataConstraintService.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: 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

示例7: buildView

 /**
  * {@inheritDoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $children = $form->all();
     $view->vars['value']['type'] = $children['type']->getViewData();
     $view->vars['value']['value'] = $children['value']->getViewData();
     $view->vars['show_filter'] = $options['show_filter'];
 }
开发者ID:ramunasd,项目名称:platform,代码行数:10,代码来源:DictionaryFilterType.php

示例8: buildView

 /**
  * {@inheritdoc}
  *
  * @param FormView      $view
  * @param FormInterface $form
  * @param array         $options
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if ($form->count() == 0) {
         return;
     }
     array_map(array($this, 'validateButton'), $form->all());
 }
开发者ID:pr0coder,项目名称:Inkstand,代码行数:14,代码来源:FormActionsType.php

示例9: getErrorMessages

 /**
  * Returns an array with form fields errors
  *
  * @param FormInterface $form
  * @param bool|false $useLabels
  * @param array $errors
  * @return array
  */
 public function getErrorMessages(FormInterface $form, $useLabels = false, $errors = array())
 {
     if ($form->count() > 0) {
         foreach ($form->all() as $child) {
             if (!$child->isValid()) {
                 $errors = $this->getErrorMessages($child, $useLabels, $errors);
             }
         }
     }
     foreach ($form->getErrors() as $error) {
         if ($useLabels) {
             $fieldNameData = $this->getErrorFormLabel($form);
         } else {
             $fieldNameData = $this->getErrorFormId($form);
         }
         $fieldName = $fieldNameData;
         if ($useLabels) {
             /**
              * @ignore
              */
             $fieldName = $this->translator->trans($fieldNameData['label'], array(), $fieldNameData['domain']);
         }
         $errors[$fieldName] = $error->getMessage();
     }
     return $errors;
 }
开发者ID:auamarto,项目名称:crud-bundle,代码行数:34,代码来源:FormErrorHandler.php

示例10: finishView

 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     foreach ($form->all() as $identifier => $child) {
         if (false === $child->getConfig()->getOption('serialize_only')) {
             continue;
         }
         unset($view->children[$identifier]);
     }
 }
开发者ID:nuxwin,项目名称:SimpleThingsFormSerializerBundle,代码行数:9,代码来源:SerializerTypeExtension.php

示例11: __construct

 public function __construct(FormInterface $form)
 {
     $this->name = $form->getName();
     foreach ($form->getErrors() as $error) {
         $this->errors[] = $error;
     }
     foreach ($form->all() as $child) {
         $this->children[] = new static($child);
     }
 }
开发者ID:alekitto,项目名称:serializer,代码行数:10,代码来源:SerializableForm.php

示例12: convertInputToSubmittedData

 /**
  * @param InputInterface $input
  * @param FormInterface  $form
  *
  * @return array
  */
 private function convertInputToSubmittedData(InputInterface $input, FormInterface $form)
 {
     $submittedData = [];
     // we don't need to do this recursively, since command options are one-dimensional (or are they?)
     foreach ($form->all() as $name => $field) {
         if ($input->hasOption($name)) {
             $submittedData[$name] = $input->getOption($name);
         }
     }
     return $submittedData;
 }
开发者ID:bangpound,项目名称:symfony-console-form,代码行数:17,代码来源:UseInputOptionsAsEventDataEventSubscriber.php

示例13: getFormChildErrorMessages

 /**
  * @param FormInterface $form
  * @return array
  */
 protected function getFormChildErrorMessages(FormInterface $form)
 {
     $errors = [];
     foreach ($form->all() as $child) {
         if (!empty($child) && !$child->isValid()) {
             foreach ($this->getErrorMessages($child) as $error) {
                 $errors[] = $error;
             }
         }
     }
     return $errors;
 }
开发者ID:dhaarbrink,项目名称:SymfonyRestApiBundle,代码行数:16,代码来源:FormValidationException.php

示例14: getFormChildErrorMessages

 /**
  * @param FormInterface $form
  * @return array
  */
 protected function getFormChildErrorMessages(FormInterface $form)
 {
     $errors = [];
     foreach ($form->all() as $child) {
         if ($this->shouldAddChildErrorMessage($child)) {
             foreach ($this->getErrorMessages($child) as $error) {
                 $errors[] = $error;
             }
         }
     }
     return $errors;
 }
开发者ID:mediamonks,项目名称:rest-api-bundle,代码行数:16,代码来源:FormValidationException.php

示例15: getFullAddress

 /**
  * @param mixed         $data
  * @param FormInterface $form
  * 
  * @return mixed
  * 
  * @throws \InvalidArgumentException
  */
 public function getFullAddress($data, FormInterface $form)
 {
     $fields = array();
     foreach ($form->all() as $field) {
         $options = $field->getConfig()->getOptions();
         if (isset($options['geo_code_field']) && true == $options['geo_code_field']) {
             $fields[] = $data[$field->getName()];
         }
     }
     if (count($fields)) {
         return implode(' ', $fields);
     }
     throw new \InvalidArgumentException('GeoDataAdapter address field mismatch');
 }
开发者ID:Remiii,项目名称:PUGXGeoFormBundle,代码行数:22,代码来源:GeoDataAdapter.php


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