File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 1414
1515class 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 );
You can’t perform that action at this time.
0 commit comments