I have this EAV "abn" which is required during customer registration and can only be modified by administrator, so no need for it in frontend customer edit.
"customer_account_edit" flag is common to both frontend and backend. remove it, EAV cannot be modified from administration, keep it, frontend account edit shows error "abn is required value".
I can use a hidden field or hide the field with CSS in frontend, but is there a better way to do this ?
$customerSetup->addAttribute(Customer::ENTITY, 'abn', [
'type' => 'varchar',
'label' => 'ABN',
'input' => 'text',
'required' => true,
'visible' => true,
'user_defined' => true,
'sort_order' => 10,
'position' => 10,
'system' => 0,
'unique' => false,
'is_used_in_grid' => false,
'is_visible_in_grid' => false,
'is_html_allowed_on_front' => true,
'visible_on_front' => true
]);
$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'abn')
->addData([
'attribute_set_id' => $attributeSetId,
'attribute_group_id' => $attributeGroupId,
'used_in_forms' => ['customer_account_create','adminhtml_checkout','adminhtml_customer', 'customer_account_edit', 'checkout_register'],
]);