I want to Create Custom Customer attribute for magento 2.
Which include in admin side at Customer creation time only.
After customer Create we want to just display it on customer Edit page as in disable state. admin can't edit it after first insert just readonly mode.
How to do that?
My custom Customer attribute code:
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$customerSetup->addAttribute(\Magento\Customer\Model\Customer::ENTITY, 'custom_attr', [
'type' => 'varchar',
'label' => 'Customer Position',
'input' => 'text',
'source' => '',
'required' => false,
'visible' => true,
'position' => 999,
'system' => false,
'backend' => ''
]);
$attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'custom_attr')
->addData(['used_in_forms' => [
'adminhtml_customer'
]]);
$attribute->save();