I created a new field on the customer form in the admin. I did so, with an EAV attribute like this inside the InstallData:
$customerSetup->addAttribute(Customer::ENTITY, self::DOCUMENT_NUMBER, [ 'type' => 'varchar', 'label' => 'Document Number', 'input' => 'text', 'required' => true, 'visible' => true, 'user_defined' => true, 'searchable' => true, 'visible_on_front' => true, 'unique' => true, 'sort_order' => 31, 'position' => 31, 'system' => 0, ]);
It worked and I can see and save data using the customer form. The problem is that whenever I try to edit a costumer, it throws an error saying: The value of attribute "Document Number" must be unique. This would make sense if I were trying to create a new customer with an already used 'Document Number' but since I'm doing an updated on an existing record it should not give me this error.
Am I missing some configuration? Thanks.