質問

I have generated CRUD on an entity "paymentvalues", but I need to modify the form so it would looks better. It worked fine on its own but when I started to work with things its not working anymore. I haven't changed in the controller so it's working perfectly well, the problem comes with twig, here's my view:

<form action="{{ path('paymentvalues_update', {'id':'1'}) }}" 
{{ form_enctype(edit_form) }} method="PUT">
{{form_widget(edit_form)}}
{{form_end(edit_form)}}

$app/console router:debug ,gives the following

paymentvalues_update                      PUT      ANY    ANY  /paymentvalues/{id}

When I run this, I get a blank screen. Using exit(0); is figured out that it doesn't get into the updateAction at all. so I guess the problem is with the tag ?

役に立ちましたか?

解決

Try not to alter the form this way. You can easily generate the action URL in controller and pass it as a form option to your form type. In buildForm() method, use the $options array and set the action from that option. You can also define form method in the buildForm() method. I never experimented with enctype, but I guess the approach would be similar.

A beautiful example how your twig template with a form should look like:

https://gist.github.com/anonymous/ad547a809ce2d6bdbc75

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top