|
- {% form_theme form with easyadmin_config('design.form_theme') only %}
-
- {% set _entity_config = easyadmin_entity(app.request.query.get('entity')) %}
- {% set _entity_id = attribute(entity, _entity_config.primary_key_field_name) %}
- {% trans_default_domain _entity_config.translation_domain %}
-
- {% set _trans_parameters = { '%entity_name%': _entity_config.name|trans, '%entity_label%': _entity_config.label|trans, '%entity_id%': _entity_id } %}
-
- {% extends _entity_config.templates.layout %}
-
- {% block body_id 'easyadmin-edit-' ~ _entity_config.name ~ '-' ~ _entity_id %}
- {% block body_class 'edit edit-' ~ _entity_config.name|lower %}
-
- {% block content_title %}
- {% apply spaceless %}
- {% set _default_title = 'edit.page_title'|trans(_trans_parameters, 'EasyAdminBundle') %}
- {{ _entity_config.edit.title is defined ? _entity_config.edit.title|trans(_trans_parameters) : _default_title }}
- {% endapply %}
- {% endblock %}
-
- {% block content_footer_wrapper '' %}
-
- {% block main %}
- {% block entity_form %}
- {{ form(form) }}
- {% endblock entity_form %}
-
- {% block delete_form %}
- {{ include('@EasyAdmin/default/includes/_delete_form.html.twig', {
- view: 'edit',
- referer: app.request.query.get('referer', ''),
- delete_form: delete_form,
- _translation_domain: _entity_config.translation_domain,
- _trans_parameters: _trans_parameters,
- _entity_config: _entity_config,
- }, with_context = false) }}
- {% endblock delete_form %}
- {% endblock %}
-
- {% block head_stylesheets %}
- {{ parent() }}
- <link rel="stylesheet" href="{{ asset('bundles/lcshop/css/backend/adminlte/plugins/jquery-ui/jquery-ui.min.css') }}">
- {% endblock %}
-
- {% block body_javascript %}
- {{ parent() }}
-
- <script src="{{ asset('bundles/lcshop/js/backend/plugin/jquery-ui/jquery-ui.min.js') }}"></script>
-
-
- {#<script type="text/javascript">
- $(function() {
- $('.edit-form').areYouSure({ 'message': '{{ 'form.are_you_sure'|trans({}, 'EasyAdminBundle')|e('js') }}' });
-
- const entityForm = document.querySelector('form.edit-form');
- const formSubmitButton = entityForm.querySelector('button[type="submit"]');
- const inputFieldsSelector = 'input,select,textarea';
-
- // Adding visual feedback for invalid fields: any ".form-group" with invalid fields
- // receives "has-error" class. The class is removed on click on the ".form-group"
- // itself to support custom/complex fields.
- formSubmitButton.addEventListener('click', function() {
- entityForm.querySelectorAll(inputFieldsSelector).forEach(function (input) {
- if (!input.validity.valid) {
- const formGroup = input.closest('div.form-group');
-
- formGroup.classList.add('has-error');
-
- formGroup.addEventListener('click', function onFormGroupClick() {
- formGroup.classList.remove('has-error');
- formGroup.removeEventListener('click', onFormGroupClick);
- });
- }
- });
- });
-
- // forms with tabs require some special treatment for errors. The problem
- // is when the field with errors is included in a tab not currently visible.
- // Browser shows this error "An invalid form control with name='...' is not focusable."
- // So, the user clicks on Submit button, the form is not submitted and the error
- // is not displayed. This JavaScript code ensures that each tab shows a badge with
- // the number of errors in it.
- formSubmitButton.addEventListener('click', function() {
- const formTabPanes = entityForm.querySelectorAll('.tab-pane');
- if (0 === formTabPanes.length) {
- return;
- }
-
- let firstNavTabItemWithError = null;
-
- formTabPanes.forEach(function (tabPane) {
- let tabPaneNumErrors = 0;
- tabPane.querySelectorAll(inputFieldsSelector).forEach(function (input) {
- if (!input.validity.valid) {
- tabPaneNumErrors++;
- }
- });
-
- let navTabItem = entityForm.querySelector('.nav-item a[href="#' + tabPane.id + '"]');
- let existingErrorBadge = navTabItem.querySelector('span.badge.badge-danger');
- if (null !== existingErrorBadge) {
- navTabItem.removeChild(existingErrorBadge);
- }
-
- if (tabPaneNumErrors > 0) {
- let newErrorBadge = document.createElement('span');
- newErrorBadge.classList.add('badge', 'badge-danger');
- newErrorBadge.title = 'form.tab.error_badge_title';
- newErrorBadge.textContent = tabPaneNumErrors;
-
- navTabItem.appendChild(newErrorBadge);
-
- if (null === firstNavTabItemWithError) {
- firstNavTabItemWithError = navTabItem;
- }
- }
- });
-
- if (firstNavTabItemWithError) {
- firstNavTabItemWithError.click();
- }
- });
-
- $('a.action-delete').on('click', function(e) {
- e.preventDefault();
-
- $('#modal-delete').modal({ backdrop: true, keyboard: true })
- .off('click', '#modal-delete-button')
- .on('click', '#modal-delete-button', function () {
- $('#delete-form').trigger('submit');
- });
- });
- });
- </script>#}
- {% endblock %}
|