$action = "submit.php";
use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; $form = $this->createFormBuilder() ->add('username', TextType::class) ->add('password', TextType::class) ->add('submit', SubmitType::class, ['label' => 'Save']) ->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $data = $form->getData(); $username = $data['username']; $password = $data['password']; // do something with the data } return $this->render('form.html.twig', [ 'form' => $form->createView(), ]);Package library: Symfony Form Component.