Skip to content

Commit

Permalink
Merge pull request sonata-project#496 from EmmanuelVella/list-id-route
Browse files Browse the repository at this point in the history
Possibility to choose list identifier route
  • Loading branch information
rande committed Jan 23, 2012
2 parents e85d34c + a0828d5 commit b79bd5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 8 additions & 0 deletions Datagrid/ListMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ public function addIdentifier($name, $type = null, array $fieldDescriptionOption
{
$fieldDescriptionOptions['identifier'] = true;

if (!isset($fieldDescriptionOptions['route']['name'])) {
$fieldDescriptionOptions['route']['name'] = 'edit';
}

if (!isset($fieldDescriptionOptions['route']['parameters'])) {
$fieldDescriptionOptions['route']['parameters'] = array();
}

return $this->add($name, $type, $fieldDescriptionOptions);
}

Expand Down
15 changes: 4 additions & 11 deletions Resources/views/CRUD/base_list_field.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,11 @@ file that was distributed with this source code.
#}

<td class="sonata-ba-list-field sonata-ba-list-field-{{ field_description.type }}" objectId="{{ admin.id(object) }}">
{% if field_description.options.identifier is defined and admin.isGranted(['EDIT', 'SHOW']) %}

{% if admin.hasroute('edit') and admin.isGranted('EDIT') %}
<a href="{{ admin.generateObjectUrl('edit', object) }}">
{% elseif admin.hasroute('show') %}
<a href="{{ admin.generateObjectUrl('show', object) }}">
{% endif %}

{% block field %}{{ value }}{% endblock %}
{% if field_description.options.identifier is defined and admin.isGranted(field_description.options.route.name|upper) and admin.hasRoute(field_description.options.route.name) %}
<a href="{{ admin.generateObjectUrl(field_description.options.route.name, object, field_description.options.route.parameters) }}">
{%- block field %}{{ value }}{% endblock -%}
</a>

{% else %}
{{ block('field') }}
{% endif %}
</td>
</td>

0 comments on commit b79bd5f

Please sign in to comment.