2013-09-03 5 views
2

Je remplaçant les modèles Skeleton de SensioGeneratorBundle comme describred dans:rendu tous les champs sauf le soumettre à symfony 2.3

http://symfony.com/doc/current/bundles/SensioGeneratorBundle/index.html#overriding-skeleton-templates

Donc, jusqu'à ce que voici tout va bien.

Dans l'un des modèles de SensioGeneratorBundle je:

# app/resources/SensioGeneratorBundle/skeleton/crud/views/new.html.twig.twig 
{% block body %} 

{{ "{% block page_title 'Incluir " ~ entity ~ "'%}" }} 

{{ "{% block body -%}" }} 

    {{ '{{ form(form) }}' }} 

    {% set hide_edit, hide_delete = true, true %} 
    {% include 'crud/views/others/record_actions.html.twig.twig' %} 
{{ "{% endblock %}" }} 
{% endblock body %} 

Cela fonctionne, mais {{form (formulaire)}} est rendu le bouton soumettre, et je veux rendre le bouton soumettre dans les record_actions .html.twig.twig.

Donc, ma question est: Comment rendre un formulaire sans rendre le bouton de soumission? En me souvenant que j'essaye de faire cela dans le modèle du squelette, en ce moment je n'ai pas les champs de la forme pour l'itérer.

Merci!

Répondre

0

La solution à ce problème est la suivante:

# app/resources/SensioGeneratorBundle/skeleton/crud/views/new.html.twig.twig 
{% block body %} 

{{ "{% block page_title 'Incluir " ~ entity ~ "'%}" }} 

{{ "{% block body -%}" }} 
{{ " {{ form_start(child) }}" }} 
{{ " {% for child in form %}" }} 
{{ "  {% if child.vars.name != 'submit' %}" }} 
{{ "  {{ form_row(child) }}" }} 
{{ "  {% endfor %}" }} 
{{ " {% endfor %}" }} 

{% set hide_edit, hide_delete = true, true %} 
{% include 'crud/views/others/record_actions.html.twig.twig' %} 

{{ "{% endblock %}" }} 
{% endblock body %} 

Et à l'intérieur record_actions.html.twig.twig

# app/resources/SensioGeneratorBundle/skeleton/crud/views/record_actions.html.twig.twig 
{{ "  {{ form_row(form.submit) }}" }} 
{{ " {{ form_end(form) }}" }} 
<ul class="record_actions"> 
    <li> 
     <a href="{{ "{{ path('" ~ route_name_prefix ~ "') }}" }}"> 
      Back to the list 
     </a> 
    </li> 
{% if ('edit' in actions) and (not hide_edit) %} 
    <li> 
     <a href="{{ "{{ path('" ~ route_name_prefix ~ "_edit', { 'id': entity.id }) }}" }}"> 
      Edit 
     </a> 
    </li> 
{% endif %} 
{% if ('delete' in actions) and (not hide_delete) %} 
    <li> 
     <form action="{{ "{{ path('" ~ route_name_prefix ~ "_delete', { 'id': entity.id }) }}" }}" method="post"> 
      <input type="hidden" name="_method" value="DELETE" /> 
      {{ '{{ form_widget(delete_form) }}' }} 
      <button type="submit">Delete</button> 
     </form> 
    </li> 
{% endif %} 
</ul> 
Questions connexes