Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created May 5, 2012 03:06
Show Gist options
  • Select an option

  • Save coreymcmahon/2599312 to your computer and use it in GitHub Desktop.

Select an option

Save coreymcmahon/2599312 to your computer and use it in GitHub Desktop.
Using the Symfony Form object in a Twig template
{# Post-back to a named route #}
<form action="{{ path('post_add') }}" method="post" {{ form_enctype(form) }}>
{# Display any messages for validation errors #}
{{ form_errors(form) }}
<div>
{# Show the fields for the 'title' parameter #}
{{ form_label(form.title) }}
{{ form_errors(form.title) }}
{{ form_widget(form.title) }}
</div>
<div>
{# Show the fields for the 'body' parameter #}
{{ form_label(form.body) }}<br/>
{{ form_errors(form.body) }}
{{ form_widget(form.body) }}
</div>
{#
Display any other parts of the form we didn't explicitly
show.
#}
{{ form_rest(form) }}
<input type="submit" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment