Skip to content

Commit 846347d

Browse files
Refactor JavsScript for UrlRewrite module edit page.
1 parent ff04f26 commit 846347d

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

app/code/Magento/UrlRewrite/view/adminhtml/templates/edit.phtml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@
1313
<?php echo $block->getChildHtml() ?>
1414

1515
<?php if ($block->getChildBlock('form')): ?>
16-
<script>
17-
require([
18-
'jquery',
19-
'mage/backend/form',
20-
'mage/backend/validation'
21-
], function($){
22-
23-
$('#edit_form').form()
24-
.validation({validationUrl: '<?php /* @escapeNotVerified */ echo $block->getValidationUrl() ?>'});
25-
26-
});
16+
<script type="text/x-magento-init">
17+
{
18+
"#edit_form": {
19+
"Magento_UrlRewrite/js/url-rewrite-validation" : {
20+
"url": "<?= $block->escapeUrl($block->getValidationUrl()) ?>"
21+
}
22+
}
23+
}
2724
</script>
2825
<?php endif; ?>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'mage/backend/form',
9+
'mage/backend/validation'
10+
], function ($) {
11+
'use strict';
12+
13+
return function (data, element) {
14+
15+
$(element).form().validation({
16+
validationUrl: data.url
17+
});
18+
};
19+
});

0 commit comments

Comments
 (0)