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


PHP Form::all方法代码示例

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


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

示例1: convertFormToArray

 private function convertFormToArray(GenericSerializationVisitor $visitor, Form $data)
 {
     $isRoot = null === $visitor->getRoot();
     $form = new \ArrayObject();
     $errors = [];
     foreach ($data->getErrors() as $error) {
         $errors[] = $this->getErrorMessage($error);
     }
     if (!empty($errors)) {
         $form['errors'] = $errors;
     }
     $children = [];
     foreach ($data->all() as $child) {
         if ($child instanceof Form) {
             $children[$child->getName()] = $this->convertFormToArray($visitor, $child);
         }
     }
     if (!empty($children)) {
         $form['children'] = $children;
     }
     if ($isRoot) {
         $visitor->setRoot($form);
     }
     return $form;
 }
开发者ID:koesie10,项目名称:LuaSerializer,代码行数:25,代码来源:LuaFormHandler.php

示例2: removeExtraFields

 /**
  * Get rid on any fields that don't appear in the form
  *
  * @param Request $request
  * @param Form $form
  */
 protected function removeExtraFields(Request $request, Form $form)
 {
     $data = $request->request->all();
     $children = $form->all();
     $data = array_intersect_key($data, $children);
     $request->request->replace($data);
 }
开发者ID:dark-bm,项目名称:mdtgeneratorbundle,代码行数:13,代码来源:MDTController.php

示例3: getErrorMessages

 protected function getErrorMessages(\Symfony\Component\Form\Form $form, $name)
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         $errors[] = $error->getMessage();
     }
     foreach ($form->all() as $child) {
         $type = $child->getConfig()->getType()->getName();
         if ($child->count() && $type !== 'choice') {
             $childErrors = $this->getErrorMessages($child, $child->getName());
             if (sizeof($childErrors)) {
                 $errors = array_merge($errors, $childErrors);
             }
         } else {
             if (!$child->isValid()) {
                 if ($name == "responsable1" || $name == "responsable2") {
                     $errors[$child->getParent()->getParent()->getName() . '_' . $name . '_' . $child->getName()] = $this->getErrorMessages($child, $child->getName());
                 } else {
                     $errors[$name . '_' . $child->getName()] = $this->getErrorMessages($child, $child->getName());
                 }
             }
         }
     }
     return $errors;
 }
开发者ID:JM-PFC,项目名称:CEIP-ST,代码行数:25,代码来源:FestivosController.php

示例4: getErrorsFromSubForm

 /**
  * @param Form $form The form subject to validation
  * @param string $prefix The field name prefix (concatenation of parents names).
  * @return array
  */
 private function getErrorsFromSubForm(Form $form, $prefix)
 {
     $errors = array();
     foreach ($form->all() as $child) {
         $errors = array_merge($errors, $this->getErrorsArray($child, $prefix), $this->getErrorsFromSubForm($child, sprintf('%s[%s]', $prefix, $child->getName())));
     }
     return $errors;
 }
开发者ID:blab2015,项目名称:seh,代码行数:13,代码来源:AbstractFormErrorsHelper.php

示例5: groupChild

 /**
  * {@inheritdoc}
  */
 protected function groupChild(Form $form)
 {
     $group_child = array();
     foreach ($form->all() as $child) {
         $group_child[substr($child->getName(), 0, -1)][] = $child;
     }
     return $group_child;
 }
开发者ID:zk2,项目名称:admin-panel-bundle,代码行数:11,代码来源:QueryBuilder.php

示例6: 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

示例7: getErrors

 /**
  * @return array
  */
 protected function getErrors()
 {
     $errors = [];
     $generalErrors = [];
     foreach ($this->form->getErrors() as $error) {
         $generalErrors[] = $error->getMessage();
     }
     if (!empty($generalErrors)) {
         $errors['general'] = $generalErrors;
     }
     foreach ($this->form->all() as $field) {
         $fieldErrors = [];
         foreach ($field->getErrors() as $error) {
             $fieldErrors[] = $error->getMessage();
         }
         if (!empty($fieldErrors)) {
             $errors[$field->getName()] = $fieldErrors;
         }
     }
     return $errors;
 }
开发者ID:dominikmatt,项目名称:sulu-form-bundle,代码行数:24,代码来源:FormController.php

示例8: getForm

 /**
  * Returns instance of SymfonyForm and fills it with fields from $_fields.
  * Checks whether all $_fields are already in the SymfonyForm and adds
  * them if necessary.
  *
  * @return SymfonyForm         Returns assigned form
  */
 public function getForm()
 {
     if (!$this->_form) {
         $this->_form = $this->_initialiseForm();
     }
     $formFields = $this->_form->all();
     foreach ($this->_fields as $name => &$fieldArray) {
         if (!array_key_exists($name, $formFields)) {
             $this->_addFieldToSymfonyForm($fieldArray);
         }
     }
     return $this->_form;
 }
开发者ID:mothership-ec,项目名称:cog,代码行数:20,代码来源:Handler.php

示例9: removeFields

 /**
  * This function remove fields available if there are not present in the $data array
  * The data array might come from $request->request->all().
  *
  * This can be usefull if you don't want to send all fields will building an api. As missing
  * fields will be threated like null values.
  *
  * @param array $data
  * @param Form  $form
  */
 public static function removeFields(array $data, Form $form)
 {
     $diff = array_diff(array_keys($form->all()), array_keys($data));
     foreach ($diff as $key) {
         $form->remove($key);
     }
     foreach ($data as $name => $value) {
         if (!is_array($value)) {
             continue;
         }
         self::removeFields($value, $form[$name]);
     }
 }
开发者ID:nfouka,项目名称:jobbet_sf2.5,代码行数:23,代码来源:FormHelper.php

示例10: getErrorMessages

 /**
  * @param Form $form
  *
  * @return array
  */
 public function getErrorMessages(Form $form)
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         $errors[] = $error->getMessage();
     }
     foreach ($form->all() as $child) {
         if (!$child->isValid()) {
             $errors[$child->getName()] = $this->getErrorMessages($child);
         }
     }
     return $errors;
 }
开发者ID:SalmaAbdelhady,项目名称:Blog,代码行数:18,代码来源:APIHelper.php

示例11: getErrorMessages

 public function getErrorMessages(BaseForm $form)
 {
     $errorMessages = [];
     if (!$form->isValid()) {
         $formData = $form->all();
         foreach ($formData as $name => $item) {
             if (!$item->isValid()) {
                 $errorMessages[] = $name . ' - ' . $item->getErrors(true);
             }
         }
     }
     return implode(PHP_EOL, $errorMessages);
 }
开发者ID:bgamrat,项目名称:crispy-octo-parakeet,代码行数:13,代码来源:Form.php

示例12: getFormErrors

 /**
  * @return array
  */
 public function getFormErrors()
 {
     $errors = array();
     foreach ($this->form->getErrors() as $key => $error) {
         $errors[$key] = $error->getMessage();
     }
     // Get errors from children
     foreach ($this->form->all() as $child) {
         if (!$child->isValid()) {
             $errors[$child->getName()] = $this->getFormErrors($child);
         }
     }
     return $errors;
 }
开发者ID:CPASimUSante,项目名称:PathBundle,代码行数:17,代码来源:AbstractHandler.php

示例13: getErrorMessages

 protected function getErrorMessages(Form $form)
 {
     $errors = array();
     foreach ($form->getErrors() as $key => $error) {
         $errors[$key] = $error->getMessage();
     }
     foreach ($form->all() as $child) {
         if (!$child->isValid()) {
             $key = sprintf('%s[%s]', $form->getName(), $child->getName());
             $errors[$key] = $this->getErrorMessages($child);
         }
     }
     return $errors;
 }
开发者ID:tarnawski,项目名称:JSONMock-backend,代码行数:14,代码来源:ApiController.php

示例14: sanitizeInput

 /**
  * Method to remove unwanted parameters in the request.
  *
  * @param array $requestData            
  * @param Form $form            
  * @return multitype:unknown
  */
 protected function sanitizeInput($requestData, Form $form)
 {
     $filteredInput = array();
     foreach ($form->all() as $childName => $child) {
         if ($child->count() > 0 && isset($requestData[$childName])) {
             foreach ($child as $grandChildName => $grandChild) {
                 $filteredInput[$childName][$grandChildName] = $this->sanitizeInput($requestData[$childName], $grandChild);
             }
         }
         if (isset($requestData[$childName])) {
             $filteredInput[$childName] = $requestData[$childName];
         }
     }
     return $filteredInput;
 }
开发者ID:aspire-lamp-hackathon,项目名称:services,代码行数:22,代码来源:AppController.php

示例15: processFormErrorsDeeply

 public static function processFormErrorsDeeply(Form $form, array &$errors)
 {
     $children = $form->all();
     if (!empty($children)) {
         foreach ($children as $childForm) {
             self::processFormErrorsDeeply($childForm, $errors);
         }
     }
     // get the errors
     $formErrors = $form->getErrors();
     foreach ($formErrors as $err) {
         $errors[] = $err->getMessage();
     }
     return;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:15,代码来源:ErrorValidationHelper.php


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