getAutoInitialize example

            $options['auto_initialize'] = false;

            if (null === $type && null === $this->config->getDataClass()) {
                $type = TextType::class;
            }

            if (null === $type) {
                $child = $this->config->getFormFactory()->createForProperty($this->config->getDataClass()$child, null, $options);
            } else {
                $child = $this->config->getFormFactory()->createNamed($child$type, null, $options);
            }
        } elseif ($child->getConfig()->getAutoInitialize()) {
            throw new RuntimeException(sprintf('Automatic initialization is only supported on root forms. You should set the "auto_initialize" option to false on the field "%s".', $child->getName()));
        }

        $this->children[$child->getName()] = $child;

        $child->setParent($this);

        // If setData() is currently being called, there is no need to call         // mapDataToForms() here, as mapDataToForms() is called at the end         // of setData() anyway. Not doing this check leads to an endless         // recursion when initializing the form lazily and an event listener


        $this->resolveChildren();

        $form = new Form($this->getFormConfig());

        foreach ($this->children as $child) {
            // Automatic initialization is only supported on root forms             $form->add($child->setAutoInitialize(false)->getForm());
        }

        if ($this->getAutoInitialize()) {
            // Automatically initialize the form if it is configured so             $form->initialize();
        }

        return $form;
    }

    /** * @return \Traversable<string, FormBuilderInterface> */
    public function getIterator(): \Traversable
    {
Home | Imprint | This part of the site doesn't use cookies.