Skip to content

Commit 38970f8

Browse files
author
Sergii Kovalenko
committed
MAGETWO-69521: Customer attribute with "Show on Storefront" set to No does not appear in backend
1 parent afc036d commit 38970f8

File tree

2 files changed

+183
-147
lines changed

2 files changed

+183
-147
lines changed

app/code/Magento/Customer/Model/Customer/DataProvider.php

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
143143
* @param Config $eavConfig
144144
* @param FilterPool $filterPool
145145
* @param FileProcessorFactory $fileProcessorFactory
146+
* @param ContextInterface $context
146147
* @param array $meta
147148
* @param array $data
149+
* @param bool $allowToShowHiddenAttributes
148150
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
149151
*/
150152
public function __construct(
@@ -350,7 +352,6 @@ protected function getAttributesMeta(Type $entityType)
350352
$meta[$code]['arguments']['data']['config']['componentType'] = Field::NAME;
351353
$meta[$code]['arguments']['data']['config']['visible'] = $this->canShowAttribute($attribute);
352354

353-
354355
$this->overrideFileUploaderMetadata($entityType, $attribute, $meta[$code]['arguments']['data']['config']);
355356
}
356357

@@ -359,30 +360,41 @@ protected function getAttributesMeta(Type $entityType)
359360
}
360361

361362
/**
362-
* Detect can we show attribute on specific form or not
363+
* Check whether the specific attribute can be shown in form: customer registration, customer edit, etc...
363364
*
364365
* @param Attribute $customerAttribute
365366
* @return bool
366367
*/
367-
private function canShowAttribute(AbstractAttribute $customerAttribute)
368+
private function canShowAttributeInForm(AbstractAttribute $customerAttribute)
368369
{
369-
$isRegistration = is_null($this->context->getRequestParam($this->getRequestFieldName()));
370-
$userDefined = (bool) $customerAttribute->getIsUserDefined();
371-
372-
if (!$userDefined) {
373-
return $customerAttribute->getIsVisible();
374-
}
370+
$isRegistration = $this->context->getRequestParam($this->getRequestFieldName()) === null;
375371

376372
if ($customerAttribute->getEntityType()->getEntityTypeCode() === 'customer') {
377-
$canShowOnForm = is_array($customerAttribute->getUsedInForms()) &&
373+
return is_array($customerAttribute->getUsedInForms()) &&
378374
(
379375
(in_array('customer_account_create', $customerAttribute->getUsedInForms()) && $isRegistration) ||
380376
(in_array('customer_account_edit', $customerAttribute->getUsedInForms()) && !$isRegistration)
381377
);
382378
} else {
383-
$canShowOnForm = is_array($customerAttribute->getUsedInForms()) &&
379+
return is_array($customerAttribute->getUsedInForms()) &&
384380
in_array('customer_address_edit', $customerAttribute->getUsedInForms());
385381
}
382+
}
383+
384+
/**
385+
* Detect can we show attribute on specific form or not
386+
*
387+
* @param Attribute $customerAttribute
388+
* @return bool
389+
*/
390+
private function canShowAttribute(AbstractAttribute $customerAttribute)
391+
{
392+
$userDefined = (bool) $customerAttribute->getIsUserDefined();
393+
if (!$userDefined) {
394+
return $customerAttribute->getIsVisible();
395+
}
396+
397+
$canShowOnForm = $this->canShowAttributeInForm($customerAttribute);
386398

387399
return ($this->allowToShowHiddenAttributes && $canShowOnForm) ||
388400
(!$this->allowToShowHiddenAttributes && $canShowOnForm && $customerAttribute->getIsVisible());

0 commit comments

Comments
 (0)