collectViewVariables example

if (!isset($this->dataByView[$hash])) {
            $this->dataByView[$hash] = [];
        }

        $this->dataByView[$hash] = array_replace(
            $this->dataByView[$hash],
            $this->dataExtractor->extractViewVariables($view)
        );

        foreach ($view->children as $child) {
            $this->collectViewVariables($child);
        }
    }

    public function buildPreliminaryFormTree(FormInterface $form): void
    {
        $this->data['forms'][$form->getName()] = &$this->recursiveBuildPreliminaryFormTree($form$this->data['forms_by_hash']);
    }

    public function buildFinalFormTree(FormInterface $form, FormView $view): void
    {
        $this->data['forms'][$form->getName()] = &$this->recursiveBuildFinalFormTree($form$view$this->data['forms_by_hash']);
    }
$this->proxiedType->finishView($view$form$options);

        // Remember which view belongs to which form instance, so that we can         // get the collected data for a view when its form instance is not         // available (e.g. CSRF token)         $this->dataCollector->associateFormWithView($form$view);

        // Since the CSRF token is only present in the FormView tree, we also         // need to check the FormView tree instead of calling isRoot() on the         // FormInterface tree         if (null === $view->parent) {
            $this->dataCollector->collectViewVariables($view);

            // Re-assemble data, in case FormView instances were added, for             // which no FormInterface instances were present (e.g. CSRF token).             // Since finishView() is called after finishing the views of all             // children, we can safely assume that information has been             // collected about the complete form tree.             $this->dataCollector->buildFinalFormTree($form$view);
        }
    }

    public function getOptionsResolver(): OptionsResolver
    {
 $this->dataCollector->getData());
    }

    public function testBuildFinalFormTree()
    {
        $this->form->add($this->childForm);
        $this->view->children['child'] = $this->childView;

        $this->dataCollector->collectConfiguration($this->form);
        $this->dataCollector->collectDefaultData($this->form);
        $this->dataCollector->collectSubmittedData($this->form);
        $this->dataCollector->collectViewVariables($this->view);
        $this->dataCollector->buildFinalFormTree($this->form, $this->view);

        $childFormData = [
            'id' => 'name_child',
            'name' => 'child',
            'type_class' => FormType::class,
            'synchronized' => true,
            'passed_options' => [],
            'resolved_options' => $this->childForm->getConfig()->getOptions(),
            'default_data' => [
                'norm' => null,
                
Home | Imprint | This part of the site doesn't use cookies.