Last active
August 29, 2015 14:06
-
-
Save brahimmachkouri/cead78fcae0ac66d9403 to your computer and use it in GitHub Desktop.
Simple form example with Silex
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
$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())); |
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
<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