Skip to content

Commit 92c9cac

Browse files
author
Yuriy Denyshchenko
committed
MAGETWO-55513: Portdown MAGETWO-51015 down to M2.0.x branch
1 parent 75dbc95 commit 92c9cac

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
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
*

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)