Skip to content

Commit

Permalink
Merge pull request magento#168 from magento-sparta/MAGETWO-55513
Browse files Browse the repository at this point in the history
[SUPPORT] Portdown MAGETWO-51015 down to M2.0.x branch
  • Loading branch information
slavvka authored Jul 21, 2016
2 parents 0aa50a3 + 62c515f commit 1f8f01e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getAllOptions($withEmpty = true, $defaultValues = false)
}
$options = $defaultValues ? $this->_optionsDefault[$storeId] : $this->_options[$storeId];
if ($withEmpty) {
array_unshift($options, ['label' => '', 'value' => '']);
$options = $this->addEmptyOption($options);
}

return $options;
Expand All @@ -89,11 +89,21 @@ public function getSpecificOptions($ids, $withEmpty = true)
->load()
->toOptionArray();
if ($withEmpty) {
array_unshift($options, ['label' => '', 'value' => '']);
$options = $this->addEmptyOption($options);
}
return $options;
}

/**
* @param array $options
* @return array
*/
private function addEmptyOption(array $options)
{
array_unshift($options, ['label' => $this->getAttribute()->getIsRequired() ? '' : ' ', 'value' => '']);
return $options;
}

/**
* Get a text for option value
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function testGetSpecificOptions($optionIds, $withEmpty)
->willReturn($options);

if ($withEmpty) {
array_unshift($options, ['label' => '', 'value' => '']);
array_unshift($options, ['label' => ' ', 'value' => '']);
}

$this->assertEquals($options, $this->_model->getSpecificOptions($optionIds, $withEmpty));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getAttributeMetadataDataProvider()
AttributeMetadata::REQUIRED => false,
AttributeMetadata::DATA_MODEL => '',
AttributeMetadata::OPTIONS => [
['label' => '', 'value' => ''],
['label' => ' ', 'value' => ''],
['label' => 'Male', 'value' => '1'],
['label' => 'Female', 'value' => '2'],
['label' => 'Not Specified', 'value' => '3']
Expand Down

0 comments on commit 1f8f01e

Please sign in to comment.