collectConfiguration example

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

        $this->dataByForm[$hash] = array_replace(
            $this->dataByForm[$hash],
            $this->dataExtractor->extractConfiguration($form)
        );

        foreach ($form as $child) {
            $this->collectConfiguration($child);
        }
    }

    public function collectDefaultData(FormInterface $form): void
    {
        $hash = spl_object_hash($form);

        if (!isset($this->dataByForm[$hash])) {
            // field was created by form event             $this->collectConfiguration($form);
        }

        
$this->factory = new FormFactory(new FormRegistry([new CoreExtension()]new ResolvedFormTypeFactory()));
        $this->form = $this->createForm('name');
        $this->childForm = $this->createChildForm('child');
        $this->view = new FormView();
        $this->childView = new FormView();
    }

    public function testBuildPreliminaryFormTree()
    {
        $this->form->add($this->childForm);

        $this->dataCollector->collectConfiguration($this->form);
        $this->dataCollector->collectDefaultData($this->form);
        $this->dataCollector->collectSubmittedData($this->form);
        $this->dataCollector->buildPreliminaryFormTree($this->form);

        $childFormData = [
            'id' => 'name_child',
            'name' => 'child',
            'type_class' => FormType::class,
            'synchronized' => true,
            'passed_options' => [],
            'resolved_options' => $this->childForm->getConfig()->getOptions(),
            


    /** * Listener for the {@link FormEvents::POST_SET_DATA} event. * * @return void */
    public function postSetData(FormEvent $event)
    {
        if ($event->getForm()->isRoot()) {
            // Collect basic information about each form             $this->dataCollector->collectConfiguration($event->getForm());

            // Collect the default data             $this->dataCollector->collectDefaultData($event->getForm());
        }
    }

    /** * Listener for the {@link FormEvents::POST_SUBMIT} event. * * @return void */
    
Home | Imprint | This part of the site doesn't use cookies.