src/SectionField/Form/Form.php
public function buildFormForSection(
        string $forHandle,
        RequestStack $requestStack,
        SectionFormOptions $sectionFormOptions = null,
        bool $csrfProtection = true
    ): FormInterface {

        $sectionConfig = $this->getSectionConfig($forHandle);
        $section = $this->getSection($sectionConfig->getFullyQualifiedClassName());

        // If we have a slug, it means we are updating something.
        // Prep so we can get the correct $sectionEntity
        $slug = null;
        if ($sectionFormOptions !== null) {
            try {
                $slug = $sectionFormOptions->getSlug();
            } catch (\Exception $exception) {
                $slug = null;
            }
        }

        // If we hava an id, it means we are updating something.
        // Prep so we can get the correct $sectionEntity
        $id = null;
        if ($sectionFormOptions !== null) {
            try {
                $id = $sectionFormOptions->getId();
            } catch (\Exception $exception) {
                $id = null;
            }
        }

        $sectionEntity = $this->getSectionEntity(
            $sectionConfig->getFullyQualifiedClassName(),
            $section,
            $slug,
            $id
        );

        $factory = $this->getFormFactory($requestStack);

        $form = $factory
            ->createBuilder(
                FormType::class,
                $sectionEntity,
                [
                    'method' => 'POST',
                    'attr' => [
                        'novalidate' => 'novalidate'
                    ],
                    'csrf_protection' => $csrfProtection,
                    'csrf_field_name' => 'token',
                    'csrf_token_id'   => 'tardigrades',
                    'allow_extra_fields' => true // We need to allow extra fields for extra section fields (ignored in the generators)
                ]
            );

        /** @var FieldInterface $field */
        foreach ($section->getFields() as $field) {
            $fieldTypeFullyQualifiedClassName = (string) $field
                ->getFieldType()
                ->getFullyQualifiedClassName();

            /** @var FieldTypeInterface $fieldType */
            $fieldType = new $fieldTypeFullyQualifiedClassName;
            $fieldType->setConfig($field->getConfig());
            $fieldType->addToForm(
                $form,
                $section,
                $sectionEntity,
                $this->sectionManager,
                $this->readSection,
                $requestStack->getCurrentRequest()
            );
        }

        $form->add('save', SubmitType::class);
        return $form->getForm();
    }
public function buildFormForSection(
        string $forHandle,
        RequestStack $requestStack,
        SectionFormOptions $sectionFormOptions = null,
        bool $csrfProtection = true
    ): FormInterface {

        $sectionConfig = $this->getSectionConfig($forHandle);
        $section = $this->getSection($sectionConfig->getFullyQualifiedClassName());

        // If we have a slug, it means we are updating something.
        // Prep so we can get the correct $sectionEntity
        $slug = null;
        if ($sectionFormOptions !== null) {
            try {
                $slug = $sectionFormOptions->getSlug();
            } catch (\Exception $exception) {
                $slug = null;
            }
        }

        // If we hava an id, it means we are updating something.
        // Prep so we can get the correct $sectionEntity
        $id = null;
        if ($sectionFormOptions !== null) {
            try {
                $id = $sectionFormOptions->getId();
            } catch (\Exception $exception) {
                $id = null;
            }
        }

        $sectionEntity = $this->getSectionEntity(
            $sectionConfig->getFullyQualifiedClassName(),
            $section,
            $slug,
            $id
        );

        $factory = $this->getFormFactory($requestStack);

        $form = $factory
            ->createBuilder(
                FormType::class,
                $sectionEntity,
                [
                    'method' => 'POST',
                    'attr' => [
                        'novalidate' => 'novalidate'
                    ],
                    'csrf_protection' => $csrfProtection,
                    'csrf_field_name' => 'token',
                    'csrf_token_id'   => 'tardigrades',
                    'allow_extra_fields' => true // We need to allow extra fields for extra section fields (ignored in the generators)
                ]
            );

        /** @var FieldInterface $field */
        foreach ($section->getFields() as $field) {
            $fieldTypeFullyQualifiedClassName = (string) $field
                ->getFieldType()
                ->getFullyQualifiedClassName();

            /** @var FieldTypeInterface $fieldType */
            $fieldType = new $fieldTypeFullyQualifiedClassName;
            $fieldType->setConfig($field->getConfig());
            $fieldType->addToForm(
                $form,
                $section,
                $sectionEntity,
                $this->sectionManager,
                $this->readSection,
                $requestStack->getCurrentRequest()
            );
        }

        $form->add('save', SubmitType::class);
        return $form->getForm();
    }
This method generates a form based on the section config.
The for handle contains the section handle, or the FQCN of the section entity.
By pasing along SectionFormOptions this method can determine of the form
is meanth to update or create new data.

@param string $forHandle
@param RequestStack $requestStack
@param SectionFormOptions|null $sectionFormOptions
@param bool $csrfProtection
@return FormInterface