Skip to content

Commit 6711694

Browse files
patelnimesh1988vijay-wagento
authored andcommitted
Refactor JavsScript for UrlRewrite module edit page
1 parent 943e2cd commit 6711694

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
?>
1111
<?= $block->getChildHtml() ?>
1212
<?php if ($block->getChildBlock('form')): ?>
13-
<script>
14-
require([
15-
'jquery',
16-
'mage/backend/form',
17-
'mage/backend/validation'
18-
], function($){
19-
$('#edit_form').form()
20-
.validation({validationUrl: '<?= $block->escapeUrl($block->getValidationUrl()) ?>'});
21-
});
13+
<script type="text/x-magento-init">
14+
{
15+
"#edit_form": {
16+
"Magento_UrlRewrite/js/url-rewrite-validation" : {
17+
"url": "<?= $block->escapeUrl($block->getValidationUrl()) ?>"
18+
}
19+
}
20+
}
2221
</script>
2322
<?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)