use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\AbstractType; class MyEntityType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('name', TextType::class) ->add('save', SubmitType::class); } }
use Symfony\Component\HttpFoundation\Request; public function createAction(Request $request) { $entity = new MyEntity(); $form = $this->createForm(MyEntityType::class, $entity); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { // process form data } // render form template return $this->render('create.html.twig', [ 'form' => $form->createView(), ]); }This example shows how to handle form submission in a controller action. It uses the "handleRequest()" method to process the form data and check if it is valid. If the form is valid, the data can be processed further. Otherwise, the form template is re-rendered with error messages. Package library: Symfony\Component\Form\Extension\Core