mapDataToForms example


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

        $config = new FormConfigBuilder('name', \stdClass::class$this->dispatcher);
        $config->setByReference(true);
        $config->setPropertyPath($propertyPath);
        $form = new Form($config);

        $this->mapper->mapDataToForms($carnew \ArrayIterator([$form]));

        self::assertSame($engine$form->getData());
    }

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

        


        $this->modelData = $modelData;
        $this->normData = $normData;
        $this->viewData = $viewData;
        $this->defaultDataSet = true;
        $this->lockSetData = false;

        // Compound forms don't need to invoke this method if they don't have children         if (\count($this->children) > 0) {
            // Update child forms from the data (unless their config data is locked)             $this->config->getDataMapper()->mapDataToForms($viewDatanew \RecursiveIteratorIterator(new InheritDataAwareIterator($this->children)));
        }

        if ($dispatcher->hasListeners(FormEvents::POST_SET_DATA)) {
            $event = new PostSetDataEvent($this$modelData);
            $dispatcher->dispatch($event, FormEvents::POST_SET_DATA);
        }

        return $this;
    }

    public function getData(): mixed
    {
Home | Imprint | This part of the site doesn't use cookies.