I’ve added a custom field to the Customer Addresses with the following UpgradeData:
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
$params = [
'label' => 'House Number',
'type' => 'varchar',
'input' => 'text',
'required' => true,
'visible' => true,
'user_defined' => true,
'position' =>999,
'system' => 0,
];
$customerSetup->addAttribute('customer_address', 'house_number', $params);
$customAttribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'house_number');
$customAttribute->setData(
'used_in_forms',
['adminhtml_checkout', 'adminhtml_customer', 'adminhtml_customer_address', 'customer_address_edit', 'customer_register_address'],
);
$customAttribute->save();
}
The field properly displays when logging into the Adminhtml area and adding a new Addresses to a customer. However, the New Address form cannot be submitted, the following error appears:
“House Number” is a required value.
Here is a screenshot:
I do believe that it is clear that a value for House Number was submitted.
What else must I do to enable this field on this form, and on other forms such as the Checkout and user’s own Account Information?