Magento 2, how to add 'textbox' into 'cancel modal'?
-
07-02-2021 - |
Solution
create module for override js file
\app\code\Magento\custombackend\etc\module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_custombackend" setup_version="0.0.1">
<sequence>
<module name="Magento_Sales"/>
</sequence>
</module>
</config>
\app\code\Magento\custombackend\view\adminhtml\requirejs-config.js
var config = {
map: {
'*': {
'Magento_Sales/order/view/post-wrapper': 'Magento_custombackend/js/order/view/post-wrapper'
}
}
};
\app\code\Magento\custombackend\view\adminhtml\web\js\order\view\post-wrapper.js
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'jquery',
'Magento_Ui/js/modal/confirm',
'mage/translate'
], function ($, confirm) {
'use strict';
/**
* @param {String} url
* @returns {Object}
*/
function getForm(url) {
return $('<form>', {
'action': url,
'method': 'POST'
}).append($('<input>', {
'name': 'form_key',
'value': window.FORM_KEY,
'type': 'hidden'
}));
}
$('#order-view-cancel-button').click(function () {
var msg = $.mage.__('Are you sure you want to cancel this order? <input type="text">'),
url = $('#order-view-cancel-button').data('url');
confirm({
'content': msg,
'actions': {
/**
* 'Confirm' action handler.
*/
confirm: function () {
getForm(url).appendTo('body').submit();
}
}
});
return false;
});
$('#order-view-hold-button').click(function () {
var url = $('#order-view-hold-button').data('url');
getForm(url).appendTo('body').submit();
});
$('#order-view-unhold-button').click(function () {
var url = $('#order-view-unhold-button').data('url');
getForm(url).appendTo('body').submit();
});
});
\app\code\Magento\custombackend\registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Magento_custombackend', __DIR__);
?>
In magento 2.2.5 this dialog text come from this path
\vendor\magento\module-sales\view\adminhtml\web\order\view\post-wrapper.js
line : 29
var msg = $.mage.__('Are you sure you want to cancel this order? <input type="text">')
add textbox like this
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange