Skip to content

Commit b322c09

Browse files
committed
⏫ Forwardport of #11349 to 2.3-develop branch
1 parent 8e77e2f commit b322c09

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/internal/Magento/Framework/Data/Form/Element/Multiselect.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public function getElementHtml()
5757
$this->addClass('select multiselect admin__control-multiselect');
5858
$html = '';
5959
if ($this->getCanBeEmpty()) {
60-
$html .= '<input type="hidden" name="' . parent::getName() . '" value="" />';
60+
$html .= '
61+
<input type="hidden" id="' . $this->getHtmlId() . '_hidden" name="' . parent::getName() . '" value="" />
62+
';
6163
}
6264
$html .= '<select id="' . $this->getHtmlId() . '" name="' . $this->getName() . '" ' . $this->serialize(
6365
$this->getHtmlAttributes()

lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/MultiselectTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@ protected function setUp()
2626
*/
2727
public function testHiddenFieldPresentInMultiSelect()
2828
{
29-
$this->_model->setDisabled(true);
29+
$fieldName = 'fieldName';
30+
$fieldId = 'fieldId';
3031
$this->_model->setCanBeEmpty(true);
32+
$this->_model->setName($fieldName);
33+
$this->_model->setId($fieldId);
3134
$elementHtml = $this->_model->getElementHtml();
32-
$this->assertContains('<input type="hidden"', $elementHtml);
35+
$this->assertContains(
36+
'<input type="hidden" id="' . $fieldId . '_hidden" name="' . $fieldName . '"',
37+
$elementHtml
38+
);
3339
}
3440

3541
/**

0 commit comments

Comments
 (0)