Skip to content

Form tweaks #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 3 additions & 24 deletions src/Symfony/Component/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ public function isSubmittedWithExtraFields()
*/
public function isValid()
{
$this->validate();

if (!parent::isValid()) {
return false;
}
Expand Down Expand Up @@ -749,9 +751,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->validate();
$this->submit(array_replace_recursive($values, $files));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work the same way for numeric keys ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

}
}

Expand Down Expand Up @@ -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;
}
}