Skip to content

Commit

Permalink
Added possibility to customize class and box class for groups on show…
Browse files Browse the repository at this point in the history
… admin page
  • Loading branch information
hason committed Apr 9, 2015
1 parent 00efb83 commit a610ed1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 23 deletions.
33 changes: 33 additions & 0 deletions Resources/doc/reference/action_show.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,40 @@ To do:
- targeting submodel fields using dot-separated notation
- (Note, if this is very similar to the form documentation it can be combined)

Group options
~~~~~~~~~~~~~

When adding a group to your show page, you may specify some options for the group itself.

- ``collapsed``: unused at the moment
- ``class``: the class for your group in the admin; by default, the value is set to ``col-md-12``.
- ``fields``: the fields in your group (you should NOT override this unless you know what you're doing).
- ``box_class``: the class for your group box in the admin; by default, the value is set to ``box box-primary``.
- ``description``: to complete
- ``translation_domain``: to complete

To specify options, do as follow:

.. code-block:: php
<?php
MyAdmin extends Admin
{
public function configureShowFields(ShowMapper $showMapper)
{
$showMapper
->tab('General') // the tab call is optional
->with('Addresses', array(
'class' => 'col-md-8',
'box_class' => 'box box-solid box-danger',
'description' => 'Lorem ipsum',
))
// ...
->end()
->end()
;
}
Customising the query used to show the object from within your Admin class
--------------------------------------------------------------------------
Expand Down
48 changes: 25 additions & 23 deletions Resources/views/CRUD/base_show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,32 @@ file that was distributed with this source code.
{{ sonata_block_render_event('sonata.admin.show.top', { 'admin': admin, 'object': object }) }}

{% for name, view_group in admin.showgroups %}
<div class="box box-primary">
{% if name %}
<div class="box-header with-border">
<h4 class="box-title">
{% block show_title %}
{{ admin.trans(name) }}
{% endblock %}
</h4>
<div class="{{ view_group.class | default('col-md-12') }}">
<div class="{{ view_group.box_class }}">
{% if name %}
<div class="box-header with-border">
<h4 class="box-title">
{% block show_title %}
{{ admin.trans(name) }}
{% endblock %}
</h4>
</div>
{% endif %}
<div class="box-body table-responsive no-padding">
<table class="table">
<tbody>
{% for field_name in view_group.fields %}
{% block show_field %}
<tr class="sonata-ba-view-container">
{% if elements[field_name] is defined %}
{{ elements[field_name]|render_view_element(object) }}
{% endif %}
</tr>
{% endblock %}
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
<div class="box-body table-responsive no-padding">
<table class="table">
<tbody>
{% for field_name in view_group.fields %}
{% block show_field %}
<tr class="sonata-ba-view-container">
{% if elements[field_name] is defined %}
{{ elements[field_name]|render_view_element(object) }}
{% endif %}
</tr>
{% endblock %}
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endfor %}
Expand Down

0 comments on commit a610ed1

Please sign in to comment.