@@ -143,8 +143,10 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
143
143
* @param Config $eavConfig
144
144
* @param FilterPool $filterPool
145
145
* @param FileProcessorFactory $fileProcessorFactory
146
+ * @param ContextInterface $context
146
147
* @param array $meta
147
148
* @param array $data
149
+ * @param bool $allowToShowHiddenAttributes
148
150
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
149
151
*/
150
152
public function __construct (
@@ -350,7 +352,6 @@ protected function getAttributesMeta(Type $entityType)
350
352
$ meta [$ code ]['arguments ' ]['data ' ]['config ' ]['componentType ' ] = Field::NAME ;
351
353
$ meta [$ code ]['arguments ' ]['data ' ]['config ' ]['visible ' ] = $ this ->canShowAttribute ($ attribute );
352
354
353
-
354
355
$ this ->overrideFileUploaderMetadata ($ entityType , $ attribute , $ meta [$ code ]['arguments ' ]['data ' ]['config ' ]);
355
356
}
356
357
@@ -359,30 +360,41 @@ protected function getAttributesMeta(Type $entityType)
359
360
}
360
361
361
362
/**
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...
363
364
*
364
365
* @param Attribute $customerAttribute
365
366
* @return bool
366
367
*/
367
- private function canShowAttribute (AbstractAttribute $ customerAttribute )
368
+ private function canShowAttributeInForm (AbstractAttribute $ customerAttribute )
368
369
{
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 ;
375
371
376
372
if ($ customerAttribute ->getEntityType ()->getEntityTypeCode () === 'customer ' ) {
377
- $ canShowOnForm = is_array ($ customerAttribute ->getUsedInForms ()) &&
373
+ return is_array ($ customerAttribute ->getUsedInForms ()) &&
378
374
(
379
375
(in_array ('customer_account_create ' , $ customerAttribute ->getUsedInForms ()) && $ isRegistration ) ||
380
376
(in_array ('customer_account_edit ' , $ customerAttribute ->getUsedInForms ()) && !$ isRegistration )
381
377
);
382
378
} else {
383
- $ canShowOnForm = is_array ($ customerAttribute ->getUsedInForms ()) &&
379
+ return is_array ($ customerAttribute ->getUsedInForms ()) &&
384
380
in_array ('customer_address_edit ' , $ customerAttribute ->getUsedInForms ());
385
381
}
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 );
386
398
387
399
return ($ this ->allowToShowHiddenAttributes && $ canShowOnForm ) ||
388
400
(!$ this ->allowToShowHiddenAttributes && $ canShowOnForm && $ customerAttribute ->getIsVisible ());
0 commit comments