Skip to content

Customer address EAV attribute does not save or validate on form submission. #4613

@dnadle

Description

@dnadle

Steps to reproduce

I have tried deploying my project with both 2.0.4 and 2.0.6; same result.

  1. Add a customer address EAV attribute of type varchar. I used the following code in UpgradeData for my module:
            $customerSetup = $this->_customerSetupFactory->create(['setup' => $setup]);
            $addrEntity = $customerSetup->getEavConfig()->getEntityType('customer_address');
            $attributeSetId = $addrEntity->getDefaultAttributeSetId();

            $attributeSet = $this->_attributeSetFactory->create();
            $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);

            $customerSetup->addAttribute('customer_address', 'shipto', [
                'type' => 'varchar',
                'label' => 'Ship-to Number',
                'input' => 'text',
                'required' => true,
                'visible' => true,
                'user_defined' => true,
                'sort_order' => 1000,
                'position' => 1000,
                'system' => 0
            ]);

            $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'shipto')
            ->addData([
                'attribute_set_id' => $attributeSetId,
                'attribute_group_id' => $attributeGroupId,
                'used_in_forms' => [
                    'adminhtml_customer_address',
                    'customer_address_edit',
                    'customer_register_address',
                ]
            ]);
  1. Observe that the field appears in the admin customer address edit form as expected.
  2. Create a new customer and add an address, making sure to populate the EAV field with a valid string. I used 'TEST'.

Expected result

  1. When the customer is saved with a properly filled address form, the customer record is saved correctly.

Actual result

  1. The UI reports "Ship-to Number" is a required value, and the address is not saved.

Other results

  1. I tried making the EAV attribute not required by modifying the database record. After that, the customer record saves without error, but the EAV attribute value is not saved. When you view the address again the field is blank.

Metadata

Metadata

Assignees

Labels

Fixed in 2.2.xThe issue has been fixed in 2.2 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedbug report

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions