Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #17861 Customer Name Prefix shows white space when extra separator is addes #20896

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions app/code/Magento/Customer/Model/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
use Magento\Config\Model\Config\Source\Nooptreq as NooptreqSource;
use Magento\Customer\Helper\Address as AddressHelper;
use Magento\Framework\Escaper;
use Magento\Store\Api\Data\StoreInterface;

/**
* Customer Options.
*/
class Options
{
/**
Expand Down Expand Up @@ -38,7 +42,7 @@ public function __construct(
/**
* Retrieve name prefix dropdown options
*
* @param null $store
* @param null|string|bool|int|StoreInterface $store
* @return array|bool
*/
public function getNamePrefixOptions($store = null)
Expand All @@ -52,7 +56,7 @@ public function getNamePrefixOptions($store = null)
/**
* Retrieve name suffix dropdown options
*
* @param null $store
* @param null|string|bool|int|StoreInterface $store
* @return array|bool
*/
public function getNameSuffixOptions($store = null)
Expand All @@ -64,7 +68,9 @@ public function getNameSuffixOptions($store = null)
}

/**
* @param $options
* Unserialize and clear name prefix or suffix options.
*
* @param string $options
* @param bool $isOptional
* @return array|bool
*
Expand All @@ -78,6 +84,7 @@ protected function _prepareNamePrefixSuffixOptions($options, $isOptional = false

/**
* Unserialize and clear name prefix or suffix options
*
* If field is optional, add an empty first option.
*
* @param string $options
Expand All @@ -91,7 +98,7 @@ private function prepareNamePrefixSuffixOptions($options, $isOptional = false)
return false;
}
$result = [];
$options = explode(';', $options);
$options = array_filter(explode(';', $options));
foreach ($options as $value) {
$value = $this->escaper->escapeHtml(trim($value));
$result[$value] = $value;
Expand Down