Skip to content

Commit 3bdc151

Browse files
committed
Tweak old input
1 parent 37f9ff0 commit 3bdc151

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/Extension/Session/SessionListener.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
class SessionListener implements EventSubscriberInterface
1616
{
17-
const UNDEFINED = '__BARRYVDH_FORMS_UNDEFINED';
18-
1917
public static function getSubscribedEvents()
2018
{
2119
return array(
@@ -29,16 +27,20 @@ public function preSet(FormEvent $event)
2927
$rootName = $form->getRoot()->getName();
3028
$parent = $form->getParent();
3129

32-
if ($parent && !($parent->getConfig()->getType()->getInnerType() instanceof ChoiceType)) {
30+
if (
31+
$parent
32+
&& $form->getName() !== '_token'
33+
&& !($parent->getConfig()->getType()->getInnerType() instanceof ChoiceType)
34+
) {
3335
$name = $this->getDottedName($form);
3436
$fullName = $this->getFullName($rootName, $name);
3537

36-
$value = old($fullName, static::UNDEFINED);
38+
// Get the input from the previous submit
39+
$oldValue = session()->getOldInput($fullName);
40+
if (! is_null($oldValue)) {
3741

38-
// Add input from the previous submit
39-
if ($form->getName() !== '_token' && $value !== static::UNDEFINED) {
4042
// Transform back to good data
41-
$value = $this->transformValue($event, $value);
43+
$value = $this->transformValue($event, $oldValue);
4244

4345
// Store on the form
4446
$event->setData($value);

0 commit comments

Comments
 (0)