Before upgrading to Magento 2.2.1, I was using version 2.1.10 and made a custom uuid attribute for customers. The attribute was added to the customer form in the admin panel and saved correctly. However after upgrading to 2.2.1, the attribute no longer shows in the form. It is still present in the eav_attributes db table so I'm not sure what has changed.
This is my code used to initial setup the attribute:
public function __construct(CustomerSetupFactory $customerSetupFactory,
AttributeSetFactory $attributeSetFactory)
{
$this->customerSetupFactory = $customerSetupFactory;
$this->attributeSetFactory = $attributeSetFactory;
}
public function install(ModuleDataSetupInterface $setup,
ModuleContextInterface $context)
{
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$setup->startSetup();
$attributesInfo = [
'uuid' => [
'label' => 'UUID',
'type' => 'varchar',
'input' => 'text',
'position' => 1000,
'visible' => true,
'required' => false,
'system' => 0,
'user_defined' => true,
'unique' => true,
]
];
$customerEntity = $customerSetup->getEavConfig()->getEntityType('customer');
$attributeSetId = $customerEntity->getDefaultAttributeSetId();
/** @var $attributeSet AttributeSet */
$attributeSet = $this->attributeSetFactory->create();
$attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
foreach ($attributesInfo as $attributeCode => $attributeParams) {
$customerSetup->addAttribute(Customer::ENTITY, $attributeCode, $attributeParams);
}
$magentoUuidAttribute = $customerSetup->getEavConfig()
->getAttribute(Customer::ENTITY, 'uuid');
$magentoUuidAttribute->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['adminhtml_customer'],
]);
$magentoUuidAttribute->save();
$setup->endSetup();
}
}
Any help would be greatly appreciated.