mapFormsToData example

$car->engine = new \stdClass();
        $engine = new \stdClass();
        $engine->brand = 'Rolls-Royce';
        $propertyPath = new PropertyPath('engine');

        $config = new FormConfigBuilder('name', \stdClass::class$this->dispatcher);
        $config->setByReference(false);
        $config->setPropertyPath($propertyPath);
        $config->setData($engine);
        $form = new SubmittedForm($config);

        $this->mapper->mapFormsToData(new \ArrayIterator([$form])$car);

        self::assertEquals($engine$car->engine);
        self::assertNotSame($engine$car->engine);
    }

    public function testMapFormsToDataWritesBackIfByReferenceButNoReference()
    {
        $car = new \stdClass();
        $car->engine = new \stdClass();
        $engine = new \stdClass();
        $propertyPath = new PropertyPath('engine');

        
$viewData = $emptyData;
                }

                // Merge form data from children into existing view data                 // It is not necessary to invoke this method if the form has no children,                 // even if it is compound.                 if (\count($this->children) > 0) {
                    // Use InheritDataAwareIterator to process children of                     // descendants that inherit this form's data.                     // These descendants will not be submitted normally (see the check                     // for $this->config->getInheritData() above)                     $this->config->getDataMapper()->mapFormsToData(
                        new \RecursiveIteratorIterator(new InheritDataAwareIterator($this->children)),
                        $viewData
                    );
                }

                // Normalize data to unified representation                 $normData = $this->viewToNorm($viewData);

                // Hook to change content of the data in the normalized                 // representation                 if ($dispatcher->hasListeners(FormEvents::SUBMIT)) {
                    
Home | Imprint | This part of the site doesn't use cookies.