I'm using the Bootstrap form theme for Symfony2 (bootstrap_3_horizontal_layout.html.twig):
I've added two buttons on a form:
$builder
// some code here ...
->add('save', 'submit', ['label' => 'save'])
->add('cancel', 'submit', ['label' => 'cancel']);
And they are rendered this way:
I need that they be situated on the same row:
How can it be achieved?
Following the
Symfony Best Practises: Add buttons in the templates, not in the form classes or the controllers.
E.g.:
{{ form_start(form) }}
{{ form_widget(form) }}
<div class="row">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" value="save" class="btn btn-primary">save</button>
<button type="submit" value="cancel" class="btn btn-default">cancel</button>
</div>
</div>
{{ form_end(form) }}
Just add a style float left to the save button. This works for me:
->add('save', 'submit', ['label' => 'save', 'attr' => array('style' => 'float: left')])
->add('cancel', 'submit', ['label' => 'cancel']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With