How to customize Form generated by Symfony CRUD?

1

I am changing the Symfony template so that CRUD already has the format I need, I could change almost everything, but now I had to change the form, to edit the css classes and other elements with div and etc. .. to stay in line with the layout I want, the Controllers and twig views (edit.html.twig.twig, index.html.twig.twig, new.html.twig.twig, show.html.twig .twig and even the actions.html.twig.twig and record_actions.html.twig) are ok, but to do the form I see that there are calls in the twig code for a form function. I would like to know where I can change the template of this form, because I want to change the layout of it. Below is a snippet of the new.html.twig.twig code.

{% block extends %}
    {{ "{% extends '::form.html.twig' %}" }} {% endblock extends %} {% block body %}
    {{ "{% block body -%}" }}
    <div class="content-wrapper-panel">
        <div class="panel form-horizontal">
            <div class="panel-heading">
                <span class="panel-title">{{ entity }} creation</span>
            </div>
            <div class="panel-body">
                {{ '{{ form(form) }}' }}
            </div>
            <div class="panel-footer">
                {% set hide_edit, hide_delete = true, true %}
                {% include 'crud/views/others/record_actions.html.twig.twig' %}
            </div>
        </div>
    </div>
    {{ "{% endblock %}" }} {% endblock body %}

Where do I find the template that generates the content of {{form (form)}} and how do I customize it?

In edit.html.twig.twig it creates the delete button by the following command:

{% if ('delete' in actions) and (not hide_delete) %}
        {{ '{{ form(delete_form) }}' }}
    {% endif %}

Just add some DIVs that I want to remove, and leave only the form and button.

The code snippet of the edit that generates the delete button produces the following output after rendering the html:

<form name="form" method="post" action="/sbcorp/web/app_dev.php/city/2"><input type="hidden" name="_method" value="DELETE"><div id="form"><div><button type="submit" id="form_submit" name="form[submit]" class="btn btn-group">Delete</button></div><input type="hidden" id="form__token" name="form[_token]" value="cpQYW2u5jQ9eH-Ux7VOeKQMtERVno_T4h3Olshaw9js"></div></form>

I want to leave only the form, the input hidden and the button

The location where I am modifying the template of the view is being shown as the image below. I've changed all skeleton \ crud \ view and skeleton \ crud \ action

    
asked by anonymous 31.07.2014 / 14:40

1 answer

3

It is not necessary to change the framework files. To customize the way form elements are rendered, you need to copy the template files into your application files.

Read this article from the documentation to learn more:

link

    
07.08.2014 / 18:01