-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from sherlockode/fix/one-to-many-view
Fix one to many view
- Loading branch information
Showing
3 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
Resources/views/CRUD/Association/edit_one_to_many.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{# | ||
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. | ||
#} | ||
{% if not sonata_admin.field_description.hasassociationadmin %} | ||
{% for element in value %} | ||
{{ element|render_relation_element(sonata_admin.field_description) }} | ||
{% endfor %} | ||
{% else %} | ||
|
||
<div id="field_container_{{ id }}" class="field-container"> | ||
<span id="field_widget_{{ id }}" > | ||
{% if sonata_admin.edit == 'inline' %} | ||
{% if sonata_admin.inline == 'table' %} | ||
{% if form.children|length > 0 %} | ||
{% include '@SonataAdmin/CRUD/Association/edit_one_to_many_inline_table.html.twig' %} | ||
{% endif %} | ||
{% elseif form.children|length > 0 %} | ||
{% set associationAdmin = sonata_admin.field_description.associationadmin %} | ||
{% include '@SonataAdmin/CRUD/Association/edit_one_to_many_inline_tabs.html.twig' %} | ||
|
||
{% endif %} | ||
{% else %} | ||
{{ form_widget(form) }} | ||
{% endif %} | ||
|
||
</span> | ||
|
||
{% set display_create_button = sonata_admin.field_description.associationadmin.hasroute('create') | ||
and sonata_admin.field_description.associationadmin.isGranted('CREATE') | ||
and btn_add | ||
and ( | ||
sonata_admin.field_description.options.limit is not defined or | ||
form.children|length < sonata_admin.field_description.options.limit | ||
) %} | ||
|
||
{% if sonata_admin.edit == 'inline' %} | ||
|
||
{% if display_create_button %} | ||
<span id="field_actions_{{ id }}" > | ||
<a | ||
href="{{ sonata_admin.field_description.associationadmin.generateUrl( | ||
'create', | ||
sonata_admin.field_description.getOption('link_parameters', {}) | ||
) }}" | ||
onclick="return start_field_retrieve_{{ id }}(this);" | ||
class="btn btn-primary btn-sm sonata-ba-action" | ||
title="{{ btn_add|trans({}, btn_catalogue) }}" | ||
> | ||
<i class="fa fa-plus-circle"></i> | ||
{{ btn_add|trans({}, btn_catalogue) }} | ||
</a> | ||
</span> | ||
{% endif %} | ||
|
||
{# add code for the sortable options #} | ||
{% if sonata_admin.field_description.options.sortable is defined %} | ||
{% if sonata_admin.inline == 'table' %} | ||
{% include '@SonataAdmin/CRUD/Association/edit_one_to_many_sortable_script_table.html.twig' %} | ||
{% else %} | ||
{% include '@SonataAdmin/CRUD/Association/edit_one_to_many_sortable_script_tabs.html.twig' %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
{# include association code #} | ||
{% include '@SonataAdmin/CRUD/Association/edit_one_script.html.twig' %} | ||
|
||
{% else %} | ||
<span id="field_actions_{{ id }}" > | ||
{% if display_create_button %} | ||
<a | ||
href="{{ sonata_admin.field_description.associationadmin.generateUrl( | ||
'create', | ||
sonata_admin.field_description.getOption('link_parameters', {}) | ||
) }}" | ||
onclick="return start_field_dialog_form_add_{{ id }}(this);" | ||
class="btn btn-primary btn-sm sonata-ba-action" | ||
title="{{ btn_add|trans({}, btn_catalogue) }}" | ||
> | ||
<i class="fa fa-plus-circle"></i> | ||
{{ btn_add|trans({}, btn_catalogue) }} | ||
</a> | ||
{% endif %} | ||
</span> | ||
|
||
{% include '@SonataAdmin/CRUD/Association/edit_modal.html.twig' %} | ||
|
||
{% include '@SonataAdmin/CRUD/Association/edit_many_script.html.twig' %} | ||
{% endif %} | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends '@SonataDoctrineORMAdmin/Form/form_admin_fields.html.twig' %} | ||
|
||
{% block sonata_admin_orm_one_to_many_widget %} | ||
{% include '@SherlockodeSonataModular/CRUD/Association/edit_one_to_many.html.twig' %} | ||
{% endblock %} |