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