M
M
microf2020-05-04 17:57:12
symfony
microf, 2020-05-04 17:57:12

How to work with Symfony Form as a separate component?

Good afternoon. Why is it so difficult with Symphony? why so many dependencies? I want to make a simple form. Opening the Documentation

use Symfony\Component\Form\Forms;

$formFactory = Forms::createFormFactory();

And that seems to be enough. But no, you must display {{ form(form) }},
and this must be connected somewhere with some kind of extension.

And you just do
public function actionCreate() {
     $formFactory = Forms::createFormFactory();
     $form = $formFactory->createBuilder()->getForm();
     $this->twig->addExtension(new FormExtension());
     return $this->renderView('create-article.twig', ['form' => $form]);  
    }

But no, you get
Fatal error: Uncaught Twig\Error\RuntimeError: Unable to load the "Symfony\Component\Form\FormRenderer" runtime

So you have to connect it too. Is there some simpler way to work with forms in symphony? And without using, for example, inheritance from AbstractController, which also pulls its dependencies through the container?
PS I understand that it is necessary to reach this point and that it is not just that symphony is one of the best frameworks, but how is it understood then?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question