Skip to content

Instantly share code, notes, and snippets.

@hollodk
Created December 21, 2014 14:23
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 hollodk/7a65372d691f3d60c217 to your computer and use it in GitHub Desktop.
Save hollodk/7a65372d691f3d60c217 to your computer and use it in GitHub Desktop.
Embed symfony forms without classes
$form = $this->createFormBuilder();
$registration = $this->get('form.factory')->createNamedBuilder('registration');
$questionary = $this->get('form.factory')->createNamedBuilder('questionary');
$registration
->add('name', 'text')
->add('city', 'text')
;
$questionary
->add('question_1', 'text')
->add('question_2', 'choice', array(
'choices' => array('female', 'male')
))
;
$form->add($registration);
$form->add($questionary);
?>
{{ form_row(form.registration) }}
{{ form_row(form.questionary) }}
<?
$data = $form->getData();
$registration = $data['registration'];
$questionary = $data['questionary'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment