I have created custom module to create custom customer attribute and its working fine for all type i.e select,file.. but not saving the value like email type.
below is the code to create attribute
$attributeCode = 'referred_email';
$customerSetup->addAttribute(
\Magento\Customer\Model\Customer::ENTITY, $attributeCode, [
'type' => 'static',
'label' => 'Referral Email',
'input' => 'text',
'source' => '',
'required' => false,
'visible' => true,
'position' => 201,
'validate_rules' =>'{"input_validation":"email"}',
'system' => false,
'backend' => ''
]
);
// show the attribute in the following forms
$attribute = $customerSetup
->getEavConfig()
->getAttribute(
\Magento\Customer\Model\Customer::ENTITY, $attributeCode
)
->addData(
['used_in_forms' => [
'adminhtml_customer',
'adminhtml_checkout',
'customer_account_create',
'customer_account_edit'
]
]);
$attribute->save();
}
Attribute created successfully but when put email id in input type and save customer ,it not saving and display blank in field while others are working fine.
Please help what am I missing in code.