Skip to content

Commit 1f8f01e

Browse files
authored
Merge pull request #168 from magento-sparta/MAGETWO-55513
[SUPPORT] Portdown MAGETWO-51015 down to M2.0.x branch
2 parents 0aa50a3 + 62c515f commit 1f8f01e

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getAllOptions($withEmpty = true, $defaultValues = false)
6666
}
6767
$options = $defaultValues ? $this->_optionsDefault[$storeId] : $this->_options[$storeId];
6868
if ($withEmpty) {
69-
array_unshift($options, ['label' => '', 'value' => '']);
69+
$options = $this->addEmptyOption($options);
7070
}
7171

7272
return $options;
@@ -89,11 +89,21 @@ public function getSpecificOptions($ids, $withEmpty = true)
8989
->load()
9090
->toOptionArray();
9191
if ($withEmpty) {
92-
array_unshift($options, ['label' => '', 'value' => '']);
92+
$options = $this->addEmptyOption($options);
9393
}
9494
return $options;
9595
}
9696

97+
/**
98+
* @param array $options
99+
* @return array
100+
*/
101+
private function addEmptyOption(array $options)
102+
{
103+
array_unshift($options, ['label' => $this->getAttribute()->getIsRequired() ? '' : ' ', 'value' => '']);
104+
return $options;
105+
}
106+
97107
/**
98108
* Get a text for option value
99109
*

app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function testGetSpecificOptions($optionIds, $withEmpty)
145145
->willReturn($options);
146146

147147
if ($withEmpty) {
148-
array_unshift($options, ['label' => '', 'value' => '']);
148+
array_unshift($options, ['label' => ' ', 'value' => '']);
149149
}
150150

151151
$this->assertEquals($options, $this->_model->getSpecificOptions($optionIds, $withEmpty));

dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerMetadataTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function getAttributeMetadataDataProvider()
101101
AttributeMetadata::REQUIRED => false,
102102
AttributeMetadata::DATA_MODEL => '',
103103
AttributeMetadata::OPTIONS => [
104-
['label' => '', 'value' => ''],
104+
['label' => ' ', 'value' => ''],
105105
['label' => 'Male', 'value' => '1'],
106106
['label' => 'Female', 'value' => '2'],
107107
['label' => 'Not Specified', 'value' => '3']

0 commit comments

Comments
 (0)