|
| 1 | +<?php |
| 2 | +/** @var $block \Magento\Backend\Block\Widget\Form\Container */ |
| 3 | +/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */ |
| 4 | +/** @var \Magento\Framework\Escaper $escaper */ |
| 5 | +?> |
| 6 | +<?= /* @noEscape */ $block->getFormInitScripts() ?> |
| 7 | +<?php if ($block->getButtonsHtml('header')): ?> |
| 8 | + <div class="page-form-actions" <?= /* @noEscape */ $block->getUiId('content-header') ?>> |
| 9 | + <?= $block->getButtonsHtml('header') ?> |
| 10 | + </div> |
| 11 | +<?php endif; ?> |
| 12 | +<?php if ($block->getButtonsHtml('toolbar')): ?> |
| 13 | + <div class="page-main-actions"> |
| 14 | + <div class="page-actions"> |
| 15 | + <div class="page-actions-buttons"> |
| 16 | + <?= $block->getButtonsHtml('toolbar') ?> |
| 17 | + </div> |
| 18 | + </div> |
| 19 | + </div> |
| 20 | +<?php endif; ?> |
| 21 | +<?= $block->getFormHtml() ?> |
| 22 | +<?php if ($block->hasFooterButtons()): ?> |
| 23 | + <div class="content-footer"> |
| 24 | + <p class="form-buttons"><?= $block->getButtonsHtml('footer') ?></p> |
| 25 | + </div> |
| 26 | +<?php endif; ?> |
| 27 | +<?php $scriptString = <<<script |
| 28 | +
|
| 29 | +require([ |
| 30 | + 'jquery', |
| 31 | + 'uiRegistry', |
| 32 | + 'mage/backend/form', |
| 33 | + 'mage/backend/validation', |
| 34 | +], function($, registry){ |
| 35 | +
|
| 36 | + $('#edit_form').form() |
| 37 | + .validation({ |
| 38 | + validationUrl: '{$escaper->escapeUrl($block->getValidationUrl())}', |
| 39 | + highlight: function(element) { |
| 40 | + var detailsElement = $(element).closest('details'); |
| 41 | + if (detailsElement.length && detailsElement.is('.details')) { |
| 42 | + var summaryElement = detailsElement.find('summary'); |
| 43 | + if (summaryElement.length && summaryElement.attr('aria-expanded') === "false") { |
| 44 | + summaryElement.trigger('click'); |
| 45 | + } |
| 46 | + } |
| 47 | + $(element).trigger('highlight.validate'); |
| 48 | + }, |
| 49 | + submitHandler: function(form) { |
| 50 | + var isValid = this.valid(); |
| 51 | +
|
| 52 | + if (isValid) { |
| 53 | + $('.widget-ui-components').each(function (index, item) { |
| 54 | + var path = jQuery(item).data('scope'); |
| 55 | + if (registry.get(path)) { |
| 56 | + registry.get(path).source.set('params.invalid', false); |
| 57 | + registry.get(path).source.trigger('data.validate'); |
| 58 | + if (registry.get(path).source.get('params.invalid')) { |
| 59 | + $('#widget_instace_tabs_properties_section_content').trigger('highlight.validate'); |
| 60 | + isValid = false; |
| 61 | + return false; |
| 62 | + } |
| 63 | + } |
| 64 | + }); |
| 65 | + } |
| 66 | +
|
| 67 | + if (isValid) { |
| 68 | + form.submit(); |
| 69 | + } |
| 70 | + } |
| 71 | + }); |
| 72 | +
|
| 73 | +}); |
| 74 | +
|
| 75 | +script; |
| 76 | +?> |
| 77 | +<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?> |
| 78 | +<?= /* @noEscape */ $block->getFormScripts() ?> |
0 commit comments