123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- {#
- This file is part of the Sonata package.
- (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- 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 }}">
- <span id="field_widget_{{ id }}" >
- {% if sonata_admin.edit == 'inline' %}
- {% if sonata_admin.inline == 'table' %}
- {% if form.getChildren() %}
- <table class="bordered-table">
- <thead>
- <tr>
- {% for field_name, nested_field in form.getChild(0).getChildren() %}
- {% if field_name == '_delete' %}
- <th>{% trans from 'SonataAdminBundle' %}action_delete{% endtrans %}</th>
- {% else %}
- <th>{{ nested_field.get('sonata_admin').admin.trans(nested_field.vars.label) }}</th>
- {% endif %}
- {% endfor %}
- </tr>
- </thead>
- <tbody class="sonata-ba-tbody">
- {% for nested_group_field_name, nested_group_field in form.getChildren() %}
- <tr>
- {% for field_name, nested_field in nested_group_field.getChildren() %}
- <td class="sonata-ba-td-{{ id }}-{{ field_name }}">
- {% if sonata_admin.field_description.associationadmin.formfielddescriptions[field_name] is defined %}
- {{ form_widget(nested_field) }}
- {% set dummy = nested_group_field.setrendered %}
- {% else %}
- {{ form_widget(nested_field) }}
- {% endif %}
- </td>
- {% endfor %}
- </tr>
- {% endfor %}
- </tbody>
- </table>
- {% endif %}
- {% elseif form.getChildren() %}
- <div>
- {% for nested_group_field_name, nested_group_field in form.getChildren() %}
- {% for field_name, nested_field in nested_group_field.getChildren() %}
- {% if sonata_admin.field_description.associationadmin.formfielddescriptions[field_name] is defined %}
- {{ form_widget(nested_field, {
- 'inline': 'natural',
- 'edit' : 'inline'
- }) }}
- {% set dummy = nested_group_field.setrendered %}
- {% else %}
- {{ form_widget(nested_field) }}
- {% endif %}
- {% endfor %}
- {% endfor %}
- </div>
- {% endif %}
- {% else %}
- {{ form_widget(form) }}
- {% endif %}
- </span>
- {% if sonata_admin.edit == 'inline' %}
- {% if sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') %}
- <span id="field_actions_{{ id }}" >
- <a
- href="{{ sonata_admin.field_description.associationadmin.generateUrl('create') }}"
- onclick="return start_field_retrieve_{{ id }}(this);"
- class="sonata-ba-action"
- >
- <img
- src="{{ asset('bundles/sonataadmin/famfamfam/add.png') }}"
- alt="{% trans from 'SonataAdminBundle' %}btn_add{% endtrans %}"
- />
- </a>
- </span>
- {% endif %}
- {# add code for the sortable options #}
- {% if sonata_admin.field_description.options.sortable is defined %}
- <script type="text/javascript">
- jQuery('div#field_container_{{ id }} tbody.sonata-ba-tbody').sortable({
- axis: 'y',
- opacity: 0.6,
- items: 'tr',
- stop: apply_position_value_{{ id }}
- });
- function apply_position_value_{{ id }}() {
- // update the input value position
- jQuery('div#field_container_{{ id }} tbody.sonata-ba-tbody td.sonata-ba-td-{{ id }}-position').each(function(index, element) {
- // remove the sortable handler and put it back
- jQuery('span.sonata-ba-sortable-handler', element).remove();
- jQuery(element).append('<span class="sonata-ba-sortable-handler ui-icon ui-icon-grip-solid-horizontal"></span>');
- jQuery('input', element).hide();
- });
- jQuery('div#field_container_{{ id }} tbody.sonata-ba-tbody td.sonata-ba-td-{{ id }}-position input').each(function(index, value) {
- jQuery(value).val(index + 1);
- });
- }
- // refresh the sortable option when a new element is added
- jQuery('#sonata-ba-field-container-{{ id }}').bind('sonata.add_element', function() {
- apply_position_value_{{ id }}();
- jQuery('div#field_container_{{ id }} tbody.sonata-ba-tbody').sortable('refresh');
- });
- apply_position_value_{{ id }}();
- </script>
- {% endif %}
- {# include association code #}
- {% include 'SonataDoctrineORMAdminBundle:CRUD:edit_orm_one_association_script.html.twig' %}
- {% else %}
- <span id="field_actions_{{ id }}" >
- {% if sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') %}
- <a
- href="{{ sonata_admin.field_description.associationadmin.generateUrl('create') }}"
- onclick="return start_field_dialog_form_add_{{ id }}(this);"
- class="sonata-ba-action"
- >
- <img
- src="{{ asset('bundles/sonataadmin/famfamfam/add.png') }}"
- alt="{% trans from 'SonataAdminBundle' %}btn_add{% endtrans %}"
- />
- </a>
- {% endif %}
- </span>
- <div style="display: none" id="field_dialog_{{ id }}">
- </div>
- {% include 'SonataDoctrineORMAdminBundle:CRUD:edit_orm_many_association_script.html.twig' %}
- {% endif %}
- </div>
- {% endif %}
|