<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var $block \Magento\Backend\Block\Widget\Form\Container */
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
?>
<?= /* @noEscape */ $block->getFormInitScripts() ?>
<?php if ($block->getButtonsHtml('header')): ?>
    <div class="page-form-actions" <?= /* @noEscape */ $block->getUiId('content-header') ?>>
        <?= $block->getButtonsHtml('header') ?>
    </div>
<?php endif; ?>
<?php if ($block->getButtonsHtml('toolbar')): ?>
    <div class="page-main-actions">
        <div class="page-actions">
            <div class="page-actions-buttons">
                <?= $block->getButtonsHtml('toolbar') ?>
            </div>
        </div>
    </div>
<?php endif; ?>
<?= $block->getFormHtml() ?>
<?php if ($block->hasFooterButtons()): ?>
    <div class="content-footer">
        <p class="form-buttons"><?= $block->getButtonsHtml('footer') ?></p>
    </div>
<?php endif; ?>
<?php $scriptString = <<<script

require([
    'jquery',
    'mage/mage'
], function($){

    $('#edit_form').mage('form').mage('validation', {
            validationUrl: '{$block->escapeJs($block->getValidationUrl())}',
            highlight: function(element) {
                var detailsElement = $(element).closest('details');
                if (detailsElement.length && detailsElement.is('.details')) {
                    var summaryElement = detailsElement.find('summary');
                    if (summaryElement.length && summaryElement.attr('aria-expanded') === "false") {
                        summaryElement.trigger('click');
                    }
                }
                $(element).trigger('highlight.validate');
            }
    });
});

script;
?>
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?>
<?= /* @noEscape */ $block->getFormScripts() ?>
