From fe359646c0a1e1c93b10447993c2dc910fee61f6 Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Thu, 17 Feb 2011 23:29:28 +0100 Subject: [PATCH 1/2] replaced deepArrayMerge() with PHP internal array_replace_recursive() --- src/Symfony/Component/Form/Form.php | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index d8a6e38174b35..95d0932add802 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -749,7 +749,7 @@ public function bind(Request $request, $data = null) $values = $request->request->get($this->getName(), array()); $files = $request->files->get($this->getName(), array()); - $this->submit(self::deepArrayUnion($values, $files)); + $this->submit(array_replace_recursive($values, $files)); $this->validate(); } @@ -940,25 +940,4 @@ public function isEmpty() return true; } - - /** - * Merges two arrays without reindexing numeric keys. - * - * @param array $array1 An array to merge - * @param array $array2 An array to merge - * - * @return array The merged array - */ - static protected function deepArrayUnion($array1, $array2) - { - foreach ($array2 as $key => $value) { - if (is_array($value) && isset($array1[$key]) && is_array($array1[$key])) { - $array1[$key] = self::deepArrayUnion($array1[$key], $value); - } else { - $array1[$key] = $value; - } - } - - return $array1; - } } From 8b257ca35900ec27dd797574e01ada9451a340c7 Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Thu, 17 Feb 2011 23:30:39 +0100 Subject: [PATCH 2/2] moved the call to validate() from bind() to isValid() to allow further changes to the subject object before validation --- src/Symfony/Component/Form/Form.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 95d0932add802..597964c7e7974 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -523,6 +523,8 @@ public function isSubmittedWithExtraFields() */ public function isValid() { + $this->validate(); + if (!parent::isValid()) { return false; } @@ -750,8 +752,6 @@ public function bind(Request $request, $data = null) $files = $request->files->get($this->getName(), array()); $this->submit(array_replace_recursive($values, $files)); - - $this->validate(); } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy