Skip to content

Commit daeaa21

Browse files
author
Eric Claeren
committed
24070 - Allowed multivalue form elements to submit data to website/group/store entities.
Multivalue elements input[] gets removed and not posted to the website/group/store controller.
1 parent 89cf888 commit daeaa21

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/code/Magento/Backend/view/adminhtml/web/js/validate-store.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,17 @@ define([
5050
options = $.data(form, 'validator').settings;
5151

5252
if ($(form).validation('isValid')) {
53+
const counts = {};
5354
$.each($(form).serializeArray(), function () {
54-
formData[this.name] = this.value || '';
55+
let name = this.name;
56+
counts[name] = (counts[name] || 0) + 1;
57+
if (formData[name]) {
58+
const replacement = '[' + (counts[name] - 1) + ']';
59+
name = name.replace(new RegExp(/\[\]$/g), replacement);
60+
}
61+
formData[name] = this.value || '';
5562
});
63+
5664
requestData = {
5765
action: $(form).attr('action'),
5866
data: formData

0 commit comments

Comments
 (0)