I'm really stuck with this thing. I added a customer address attribute with the following install data in my custom module

 namespace Vendor\Module\Setup;

 use Magento\Framework\Setup\InstallDataInterface;
 use Magento\Framework\Setup\ModuleContextInterface;
 use Magento\Framework\Setup\ModuleDataSetupInterface;
 use Magento\Customer\Model\Customer;
 use Magento\Customer\Setup\CustomerSetupFactory;

 class InstallData implements InstallDataInterface

private $customerSetupFactory;

 * Constructor
 * @param \Magento\Customer\Setup\CustomerSetupFactory $customerSetupFactory
public function __construct(
    CustomerSetupFactory $customerSetupFactory
) {
    $this->customerSetupFactory = $customerSetupFactory;

 * {@inheritdoc}
public function install(
    ModuleDataSetupInterface $setup,
    ModuleContextInterface $context
) {
    $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

    $customerSetup->addAttribute(\Magento\Customer\Model\Indexer\Address\AttributeProvider::ENTITY, 'fiscal_code', [
        'label' => 'Codice Fiscale',
        'input' => 'text',
        'type' => 'varchar',
        'source' => '',
        'required' => false,
        'position' => 66,
        'visible' => true,
        'system' => false,
        'is_used_in_grid' => false,
        'is_visible_in_grid' => false,
        'is_filterable_in_grid' => false,
        'is_searchable_in_grid' => false,
        'backend' => ''

    $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'fiscal_code')
        ->addData(['used_in_forms' => [

The attribute is showing in admin panel and I can save it from there.

It's also correctly shown in checkout both in shipping an billing address forms, but no way to save it both for guest and registered users.

I'm using Magento 2.2.5

Any suggestion?


Looks like your attribute is not assigned to an attribute set. The link below shows you how to have a customer attribute saved.

Magento2 : user define customer attribute not save value while create / save from admin

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.