Last active
August 29, 2015 14:20
-
-
Save sergiors/75bbadcece53ed89f632 to your computer and use it in GitHub Desktop.
symfony form
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
class User extends AbstractType | |
{ | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder | |
->add('name', 'text') | |
->add('email', 'email') | |
->add('password', 'password'); | |
} | |
public function getName() | |
{ | |
return 'user'; | |
} | |
} | |
// ... | |
user = new Entity\User(); | |
$form = $app['form.factory'] | |
->createBuilder(new UserType(), $user) | |
->getForm(); | |
$form->handleRequest($req); | |
if ($form->isValid()) { | |
$app['orm.em']->persist($user); | |
$app['orm.em']->flush(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment