Keutelvocht Keutelvocht - 28 days ago 6
Twig Question

form not rendering correctly in modal

I try to render a form with ajax and show it in a modal.
But the fom tags in the modal just appears next to eachother when i check the source code in my browser. How can I resolve this?

Here is my written code of the modal in:

<!-- Modal Edit client -->
<div id="editClient" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times</button>
<h4 class="modal-title">Edit Client</h4>
</div>
<div class="modal-body">
<form id="editClientForm" action="{{ path('client_details') }}" method="POST">
{{ form_widget(form) }}
<br />
<input type="submit" class="btn btn-success" value="Save changes">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</form>
</div>
</div>
</div>
</div>


The modal opens with the form fields and closes when cancel is clicked.

Here is the source code from the browser:

<div class="modal-body">
<form id="editClientForm" action="/ruben/avr_symfony/web/app_dev.php/configurator/client/details" method="POST"></form>
=> here comes all the form fields and buttons.
</div>


As you can see, it closes the form tag before putting in the form fields.

Answer Source

I found the problem.

I hade a closing table tag wich i typed as < table > instead of < / table > in my code above the modal code.

This solved the issue.