Skip to content

Commit db9be6a

Browse files
committed
MAGETWO-72624: [2.3] - [Magento Cloud] Unable to clear multiselct in attribute editor.
1 parent f16c0c4 commit db9be6a

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public function getElementHtml()
6161
<input type="hidden" id="' . $this->getHtmlId() . '_hidden" name="' . parent::getName() . '" value="" />
6262
';
6363
}
64+
if (!empty($this->_data['disabled'])) {
65+
$html .= '<input type="hidden" name="' . parent::getName() . '_disabled" value="" />';
66+
}
67+
6468
$html .= '<select id="' . $this->getHtmlId() . '" name="' . $this->getName() . '" ' . $this->serialize(
6569
$this->getHtmlAttributes()
6670
) . $this->_getUiId() . ' multiple="multiple">' . "\n";

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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ protected function setUp()
2020
}
2121

2222
/**
23-
* Verify that hidden input is present in multiselect
23+
* Verify that hidden input is present in multiselect.
2424
*
2525
* @covers \Magento\Framework\Data\Form\Element\Multiselect::getElementHtml
26+
* @return void
2627
*/
2728
public function testHiddenFieldPresentInMultiSelect()
2829
{
@@ -39,7 +40,38 @@ public function testHiddenFieldPresentInMultiSelect()
3940
}
4041

4142
/**
42-
* Verify that js element is added
43+
* Verify that hidden input is present in multiselect and it allow indicate is multiselect is disabled.
44+
*
45+
* @return void
46+
*/
47+
public function testHiddenDisabledFieldPresentInMultiSelect()
48+
{
49+
$fieldName = 'fieldName';
50+
$this->_model->setDisabled(true);
51+
$this->_model->setName($fieldName);
52+
$elementHtml = $this->_model->getElementHtml();
53+
$this->assertContains('<input type="hidden" name="' . $fieldName . '_disabled"', $elementHtml);
54+
}
55+
56+
/**
57+
* Verify that hidden input doesn't present in multiselect and it allow indicate is multiselect is disabled.
58+
*
59+
* @covers \Magento\Framework\Data\Form\Element\Multiselect::getElementHtml
60+
* @return void
61+
*/
62+
public function testHiddenDisabledFieldNotPresentInMultiSelect()
63+
{
64+
$fieldName = 'fieldName';
65+
$this->_model->setDisabled(false);
66+
$this->_model->setName($fieldName);
67+
$elementHtml = $this->_model->getElementHtml();
68+
$this->assertNotContains('<input type="hidden" name="' . $fieldName . '_disabled"', $elementHtml);
69+
}
70+
71+
/**
72+
* Verify that js element is added.
73+
*
74+
* @return void
4375
*/
4476
public function testGetAfterElementJs()
4577
{

0 commit comments

Comments
 (0)