Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ResizeDataListener::presetData and ::preBind should should pass data …

…when recreating rows
  • Loading branch information...
commit ffa26754fec590887e63e941016644a460c34070 1 parent 774ac80
Alexander authored September 20, 2011
4  src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php
@@ -90,7 +90,7 @@ public function preSetData(DataEvent $event)
90 90
 
91 91
         // Then add all rows again in the correct order
92 92
         foreach ($data as $name => $value) {
93  
-            $form->add($this->factory->createNamed($this->type, $name, null, array_replace(array(
  93
+            $form->add($this->factory->createNamed($this->type, $name, $value, array_replace(array(
94 94
                 'property_path' => '['.$name.']',
95 95
             ), $this->options)));
96 96
         }
@@ -122,7 +122,7 @@ public function preBind(DataEvent $event)
122 122
         if ($this->allowAdd) {
123 123
             foreach ($data as $name => $value) {
124 124
                 if (!$form->has($name)) {
125  
-                    $form->add($this->factory->createNamed($this->type, $name, null, array_replace(array(
  125
+                    $form->add($this->factory->createNamed($this->type, $name, $value, array_replace(array(
126 126
                         'property_path' => '['.$name.']',
127 127
                     ), $this->options)));
128 128
                 }
10  tests/Symfony/Tests/Component/Form/Extension/Core/EventListener/ResizeFormListenerTest.php
@@ -58,14 +58,14 @@ public function testPreSetDataResizesForm()
58 58
 
59 59
         $this->factory->expects($this->at(0))
60 60
             ->method('createNamed')
61  
-            ->with('text', 1, null, array('property_path' => '[1]', 'max_length' => 10))
  61
+            ->with('text', 1, 'string1', array('property_path' => '[1]', 'max_length' => 10))
62 62
             ->will($this->returnValue($this->getForm('1')));
63 63
         $this->factory->expects($this->at(1))
64 64
             ->method('createNamed')
65  
-            ->with('text', 2, null, array('property_path' => '[2]', 'max_length' => 10))
  65
+            ->with('text', 2, 'string2', array('property_path' => '[2]', 'max_length' => 10))
66 66
             ->will($this->returnValue($this->getForm('2')));
67 67
 
68  
-        $data = array(1 => 'string', 2 => 'string');
  68
+        $data = array(1 => 'string1', 2 => 'string2');
69 69
         $event = new DataEvent($this->form, $data);
70 70
         $listener = new ResizeFormListener($this->factory, 'text', array('max_length' => '10'), false, false);
71 71
         $listener->preSetData($event);
@@ -102,10 +102,10 @@ public function testPreBindResizesUpIfAllowAdd()
102 102
 
103 103
         $this->factory->expects($this->once())
104 104
             ->method('createNamed')
105  
-            ->with('text', 1, null, array('property_path' => '[1]', 'max_length' => 10))
  105
+            ->with('text', 1, 'string2', array('property_path' => '[1]', 'max_length' => 10))
106 106
             ->will($this->returnValue($this->getForm('1')));
107 107
 
108  
-        $data = array(0 => 'string', 1 => 'string');
  108
+        $data = array(0 => 'string1', 1 => 'string2');
109 109
         $event = new DataEvent($this->form, $data);
110 110
         $listener = new ResizeFormListener($this->factory, 'text', array('max_length' => 10), true, false);
111 111
         $listener->preBind($event);

0 notes on commit ffa2675

Please sign in to comment.
Something went wrong with that request. Please try again.