Created
April 17, 2011 20:29
-
-
Save flevour/924438 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Symfony\Component\HttpFoundation\RedirectResponse; | |
class UserController extends Controller | |
{ | |
/** | |
* @extra:Template() | |
*/ | |
public function indexAction() | |
{ | |
$form = GoalForm::create($this->get('form.context'), 'auth_goal'); | |
$form->bind($this->container->get('request'), $form); | |
if ($form->isValid()) { | |
$form->send($this->get('mailer')); | |
$this->get('session')->setFlash('notice', 'Message sent!'); | |
return new RedirectResponse($this->generateUrl('homepage')); | |
} | |
return array('form' => $form); | |
} | |
/** | |
* @extra:Template() | |
*/ | |
public function profileAction() | |
{ | |
$factory = $this->get('form.factory'); | |
$form = $factory->create(new TestIntegerFormType()); | |
if ($this->get('request')->getMethod() === 'POST') { | |
$form->bindRequest($this->get('request')); | |
$this->get('session')->setFlash('notice', 'integerField is ' . $form->get('integerField')->getData()); | |
return new RedirectResponse($this->generateUrl('integerFieldPage')); | |
} | |
return array('form' => $form->createView()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Symfony\Component\Form\FormBuilder; | |
use Symfony\Component\Form\Type\AbstractType; | |
class TestIntegerFormType extends AbstractType | |
{ | |
public function buildForm(FormBuilder $builder, array $options) | |
{ | |
$builder | |
->add('integerField', 'integer') | |
; | |
} | |
public function getName() | |
{ | |
return 'integerform'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment