Skip to content

Instantly share code, notes, and snippets.

@sergiors
Last active August 29, 2015 14:20
Show Gist options
  • Save sergiors/75bbadcece53ed89f632 to your computer and use it in GitHub Desktop.
Save sergiors/75bbadcece53ed89f632 to your computer and use it in GitHub Desktop.
symfony form
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