Set default value of Symfony 2 form field in Twig

hsz picture hsz · Dec 17, 2012 · Viewed 45k times · Source

Is it possible to set default value of input field in Twig ?

I am rendering form row with:

{{ form_widget(form.title) }}

I want to be able to set default value like:

{{ form_widget(form.title, {data : 'Default title'}) }}

Is it even possible ?

Answer

hsz picture hsz · Dec 17, 2012

Magic keyword for default value is value, not data.

{{ form_widget(form.title, {'value' : 'Default title'}) }}