I want to remove the mandatory validation for customer fields eg. firstname, lastname (both for frontend and admin).
I tried using UpgradeData to change the value of is_required field to 0 in the eav_attribute table.
This changes the required condition in the customer logged in page as not required for firstname and lastname.
But in the admin panel while adding new customer, the firstname field goes not required, whereas the lastname field remains required.
What can I do to remove the required field in the lastname in admin panel.
UpgradeData.php
class UpgradeData implements UpgradeDataInterface
{
public function __construct(
EavSetup $eavSetupFactory
)
{
$this->eavSetupFactory = $eavSetupFactory;
}
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
$setup->startSetup();
if (version_compare($context->getVersion(), '1.0.1', '<')) {
$this->eavSetupFactory->updateAttribute(1,5,'is_required',0,null);
$this->eavSetupFactory->updateAttribute(2,23,'is_required',0,null);
$this->eavSetupFactory->updateAttribute(1,7,'is_required',0,null);
$this->eavSetupFactory->updateAttribute(2,25,'is_required',0,null);
}
$setup->endSetup();
}