Skip to content

Instantly share code, notes, and snippets.

@saro0h
Created December 11, 2014 19:47
Show Gist options
  • Save saro0h/a7447db7cbac515aef42 to your computer and use it in GitHub Desktop.
Save saro0h/a7447db7cbac515aef42 to your computer and use it in GitHub Desktop.
<?php
//…
/**
* @Route("/contact", name="contact_new")
* @Template
*/
public function indexAction(Request $request)
{
$contact = new Contact();
$form = $this->createForm('contact', $contact);
$form->add('send', 'submit');
$form->handleRequest($request);
if ($form->isValid()) {
$this->get('vendor_mail')->send($contact);
return $this->redirect($this->generateUrl("contact_success"));
}
return [
"form" => $form->createView()
];
}
<?php
//…
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('sender', 'text')
->add('subject', 'text')
->add('message', 'textarea')
;
}
public function getName()
{
return 'contact';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment