Skip to content

Commit

Permalink
Added missing files for the preview and the refactored edit_form views
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanos Polymeneas authored and rande committed Jul 19, 2012
1 parent d863c36 commit 554c818
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
73 changes: 73 additions & 0 deletions Resources/views/CRUD/base_edit_form.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{% block form %}
{% set url = admin.id(object) ? 'edit' : 'create' %}

{% if not admin.hasRoute(url)%}
<div>
{{ "form_not_available"|trans({}, "SonataAdminBundle") }}
</div>
{% else %}
<form action="{{ admin.generateUrl(url, {'id': admin.id(object), 'uniqid': admin.uniqid}) }}" {{ form_enctype(form) }} method="POST">

{% if form.vars.errors|length > 0 %}
<div class="sonata-ba-form-error">
{{ form_errors(form) }}
</div>
{% endif %}

{% block sonata_pre_fieldsets %}{% endblock %}

{% for name, form_group in admin.formgroups %}
<fieldset {% if form_group.collapsed %}class="sonata-ba-fielset-collapsed"{% endif %}>
<legend>
{% if form_group.collapsed %}
<a href="" class="sonata-ba-collapsed" title="{% trans from 'SonataAdminBundle' %}link_expand{% endtrans %}">{{ name|trans({}, admin.translationdomain) }}</a>
{% else %}
{{ name|trans({}, admin.translationdomain) }}
{% endif %}
</legend>

<div class="sonata-ba-collapsed-fields">
{% for field_name in form_group.fields %}
{% if admin.formfielddescriptions[field_name] is defined %}
{{ form_row(form[field_name])}}
{% endif %}
{% endfor %}
</div>
</fieldset>
{% endfor %}

{% block sonata_post_fieldsets %}{% endblock %}

{{ form_rest(form) }}

{% block formactions %}
<div class="actions">
{% if app.request.isxmlhttprequest %}
{% if admin.id(object) %}
<input type="submit" class="btn primary" name="btn_update" value="{% trans from 'SonataAdminBundle' %}btn_update{% endtrans %}"/>
{% else %}
<input type="submit" class="btn" name="btn_create" value="{% trans from 'SonataAdminBundle' %}btn_create{% endtrans %}"/>
{% endif %}
{% else %}
{% if admin.supportsPreviewMode %}
<input class="btn btn-info persist-preview" name="btn_preview" type="submit" value="{% trans from 'SonataAdminBundle' %}btn_preview{% endtrans %}"/>
{% endif %}
{% if admin.id(object) %}
<input type="submit" class="btn primary" name="btn_update_and_edit" value="{% trans from 'SonataAdminBundle' %}btn_update_and_edit_again{% endtrans %}"/>
<input type="submit" class="btn" name="btn_update_and_list" value="{% trans from 'SonataAdminBundle' %}btn_update_and_return_to_list{% endtrans %}"/>

{% if admin.hasroute('delete') and admin.isGranted('DELETE', object) %}
{% trans from 'SonataAdminBundle' %}delete_or{% endtrans %}
<a class="btn danger" href="{{ admin.generateObjectUrl('delete', object) }}">{% trans from 'SonataAdminBundle' %}link_delete{% endtrans %}</a>
{% endif %}
{% else %}
<input class="btn primary" type="submit" name="btn_create_and_edit" value="{% trans from 'SonataAdminBundle' %}btn_create_and_edit_again{% endtrans %}"/>
<input class="btn" type="submit" name="btn_create_and_create" value="{% trans from 'SonataAdminBundle' %}btn_create_and_create_a_new_one{% endtrans %}"/>
{% endif %}
{% endif %}
</div>
{% endblock formactions %}
</form>
{% endif%}

{% endblock %}
55 changes: 55 additions & 0 deletions Resources/views/CRUD/preview.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}

{% extends 'SonataAdminBundle:CRUD:edit.html.twig' %}

{% block actions %}
{% endblock %}

{% block side_menu %}
{% endblock %}

{% block formactions %}
<input class="btn btn-success" type="submit" name="btn_preview_approve" value="{% trans from 'SonataAdminBundle' %}btn_preview_approve{% endtrans %}"/>
<input class="btn btn-danger" type="submit" name="btn_preview_decline" value="{% trans from 'SonataAdminBundle' %}btn_preview_decline{% endtrans %}"/>
{% endblock %}

{% block preview %}
<div class="sonata-ba-view">
{% for name, view_group in admin.showgroups %}
<table class="table table-bordered">
{% if name %}
<tr class="sonata-ba-view-title">
<td colspan="2">
{{ admin.trans(name) }}
</td>
</tr>
{% endif %}

{% for field_name in view_group.fields %}
<tr class="sonata-ba-view-container">
{% if admin.show[field_name] is defined %}
{{ admin.show[field_name]|render_view_element(object) }}
{% endif %}
</tr>
{% endfor %}
</table>
{% endfor %}
</div>
{% endblock %}

{% block form %}

<div class="sonata-preview-form-container">
{{parent()}}
</div>
{% endblock %}

0 comments on commit 554c818

Please sign in to comment.