Skip to content

Instantly share code, notes, and snippets.

@brahimmachkouri
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brahimmachkouri/cead78fcae0ac66d9403 to your computer and use it in GitHub Desktop.
Save brahimmachkouri/cead78fcae0ac66d9403 to your computer and use it in GitHub Desktop.
Simple form example with Silex
$app->register(new Silex\Provider\TranslationServiceProvider(), array(
'locale_fallbacks' => array('en'),
));
$app->register(new Silex\Provider\FormServiceProvider());
$form = $app['form.factory']->createBuilder('form')
->add('name')
->add('email')
->add('gender', 'choice', array(
'choices' => array(1 => 'male', 2 => 'female'),
'expanded' => true,
))
->getForm();
$app['twig']->render('test.twig',array('form'=>$form->createView()));
<form action="#" method="post">
{{ form_widget(form) }}
<input type="submit" name="submit" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment