diff --git a/sources/Application/TwigBase/Controller/Controller.php b/sources/Application/TwigBase/Controller/Controller.php index 718a7f74c..700742770 100644 --- a/sources/Application/TwigBase/Controller/Controller.php +++ b/sources/Application/TwigBase/Controller/Controller.php @@ -26,6 +26,7 @@ use Combodo\iTop\Application\WebPage\ErrorPage; use Combodo\iTop\Application\WebPage\iTopWebPage; use Combodo\iTop\Application\WebPage\WebPage; use Combodo\iTop\Controller\AbstractController; +use Combodo\iTop\Forms\Forms; use Dict; use Exception; use ExecutionKPI; @@ -38,11 +39,9 @@ use SetupUtils; use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Form\TwigRendererEngine; use Symfony\Component\Form\Extension\Core\Type\FormType; -use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormRenderer; -use Symfony\Component\Form\Forms; use Symfony\Component\HttpFoundation\Request; use Twig\Error\Error; use Twig\Error\SyntaxError; @@ -689,10 +688,7 @@ abstract class Controller extends AbstractController public function GetFormBuilder(string $type = FormType::class, mixed $data = null, array $options = []): FormBuilderInterface { - $oFormFactory = Forms::createFormFactoryBuilder() - ->addExtension(new HttpFoundationExtension()) - ->getFormFactory(); - return $oFormFactory->createBuilder($type, $data,$options); + return Forms::createFormFactory()->createBuilder($type, $data,$options); } public function GetForm(string $type = FormType::class, mixed $data = null, array $options = []): FormInterface diff --git a/sources/Forms/FormType/Base/DynamicFormInterface.php b/sources/Forms/FormType/Base/DynamicFormInterface.php new file mode 100644 index 000000000..ed78759ef --- /dev/null +++ b/sources/Forms/FormType/Base/DynamicFormInterface.php @@ -0,0 +1,12 @@ +getFormFactory(); + } + + /** + * Creates a form factory builder with the iTop configuration. + */ + public static function createFormFactoryBuilder(): FormFactoryBuilderInterface + { + return (new FormFactoryBuilder()) + ->addExtension(new HttpFoundationExtension()) + ->setResolvedTypeFactory(new ResolvedFormTypeFactory()); + } + + /** + * This class cannot be instantiated. + */ + private function __construct() + { + } +} \ No newline at end of file diff --git a/sources/Forms/ResolvedFormType.php b/sources/Forms/ResolvedFormType.php new file mode 100644 index 000000000..ea8e9aa1c --- /dev/null +++ b/sources/Forms/ResolvedFormType.php @@ -0,0 +1,33 @@ +