lilly
lilly

Reputation: 701

In Symfony2, how do I change button type from button to submit?

I try to use Symfony2's (v2.6.1) button widget. I want it to submit the form (meaning the rendered button should have type="submit"), but setting in the attr in TWIG doesn't work for me.

{{ form_row(form.theButton, {'attr': {'type': 'submit'}, 'label': 'the custom label I need'}) }}

I can't believe there is no such setting, so I assume I'm missing something from the docs.

Could anybody spell it out for me?

Upvotes: 0

Views: 759

Answers (2)

shirshir
shirshir

Reputation: 111

Instead of using the 'button' form field type, use the 'submit' form field type: http://symfony.com/doc/current/reference/forms/types/submit.html

Upvotes: 3

chapay
chapay

Reputation: 1315

Try to use form.submit instead of form.theButton:

{{ form_row(form.submit, 'label': 'the custom label I need'}) }}

http://symfony.com/doc/current/reference/forms/types/submit.html

Upvotes: 1

Related Questions