當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。