Skip to content

Instantly share code, notes, and snippets.

@eddymugwiza eddymugwiza/FormController Secret
Created Mar 7, 2018

What would you like to do?
namespace AppBundle\Controller;
use AppBundle\Form\UserForm;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class FormControllerTest extends Controller
* @Route("register", name="register_form")
public function createSimpleForm()
$form = $this->createForm(UserForm::class, array('action'=> $this->generateUrl("add_new_user")));
return $this->render('views/users/users.html.twig',
'userForm' => $form->createView()
* @Route("user/add", name="add_new_user")
* @param Request $request
public function processForm(Request $request)
$form = $this->createForm(UserForm::class,array('action'=> $this->generateUrl("add_new_user")));
if ($form->isSubmitted()) {
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class UserForm extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
// dump($options);die;
public function configureOptions(OptionsResolver $resolver)

This comment has been minimized.

Copy link
Owner Author

commented Mar 7, 2018

Second method in above controller serves for processing from

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.