title: How to show/save value of custom customer address attribute on address edit Magento 2
body: <p>I want to add a custom attribute on <code>customer_address</code>. I need to save the value in DB, trigger the value in frontend forms (new/edit address) and in backend also.</p>
  <p>I used the following InstallData script in order to add a new attribute:</p>
  <pre class="lang-php prettyprint-override"><code>$installer = $setup;
  $installer-&gt;startSetup();
  
  /* @var CustomerSetup $customerSetup */
  $customerSetup = $this-&gt;customerSetupFactory-&gt;create(['setup' =&gt; $setup]);
  $customerSetup-&gt;removeAttribute('customer_address', &quot;chamber_of_commerce&quot;);
  
  $customerEntity = $customerSetup-&gt;getEavConfig()-&gt;getEntityType('customer_address'); //customer
  $attributeSetId = $customerEntity-&gt;getDefaultAttributeSetId();
  
  $attributeSet = $this-&gt;attributeSetFactory-&gt;create();
  $attributeGroupId = $attributeSet-&gt;getDefaultGroupId($attributeSetId);
  
  $customerSetup-&gt;addAttribute('customer_address', 'chamber_of_commerce', [
      'type' =&gt; 'varchar',
      'label' =&gt; 'Chamber of Commerce',
      'input' =&gt; 'text',
      'required' =&gt; false,
      'visible' =&gt; true,
      'user_defined' =&gt; true,
      'system' =&gt; false,
      'sort_order' =&gt; 150
  ]);
  
  $attribute = $customerSetup-&gt;getEavConfig()-&gt;getAttribute('customer_address', 'chamber_of_commerce')
      -&gt;addData([
          'attribute_set_id' =&gt; $attributeSetId,
          'attribute_group_id' =&gt; $attributeGroupId,
          'used_in_forms'=&gt;['adminhtml_customer_address','customer_address_edit','customer_register_address']
      ]);
  
  $attribute-&gt;save();
  
  $installer-&gt;endSetup(); 
  </code></pre>
  <p>I used</p>
  <pre class="lang-php prettyprint-override"><code>'used_in_forms'=&gt;['adminhtml_customer_address','customer_address_edit','customer_register_address'] 
  </code></pre>
  <p>but it seems that only in the backend form is added automatically and also saves a new value.</p>
  <p>I manually added an input in order to show the attribute in frontend on new/edit address in CustomerAccount, but I cannot manage to get the value from DB or save a new value.</p>
  <p>I think I am missing something and I would really appreciate if someone can take a look and give a hint.</p>
  <p>I am using Magento 2.2.4</p>
  <p><strong>Update:</strong></p>
  <ol>
  <li><p>I used an observer for Magento\Customer\Model\Address in order to save the value for edit/new address from MyAccount page.</p>
  </li>
  <li><p>In order to get the value saved also from the checkout page, I used:</p>
  </li>
  </ol>
  <p>2.1. <code>extension_attributes</code> for Customer AddressInterface</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;extension_attributes for=&quot;Magento\Customer\Api\Data\AddressInterface&quot;&gt;
      &lt;attribute code=&quot;chamber_of_commerce&quot; type=&quot;string&quot; /&gt;
  &lt;/extension_attributes&gt;
  </code></pre>
  <p>2.2.  etc/fieldset:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;fieldset id=&quot;sales_convert_quote_address&quot;&gt;
      &lt;field name=&quot;chamber_of_commerce&quot;&gt;
          &lt;aspect name=&quot;to_customer_address&quot; /&gt;
          &lt;aspect name=&quot;to_order_address&quot; /&gt;
      &lt;/field&gt;
  &lt;/fieldset&gt;
  </code></pre>
  <p>2.3. plugin for Customer Address for <code>beforeUpdateData</code> function</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;type name=&quot;Magento\Customer\Model\Address&quot;&gt; 
      &lt;plugin disabled=&quot;false&quot; name=&quot;vendor_plugin_quote_model_address&quot; sortOrder=&quot;10&quot; 
          type=&quot;Vendor\Module\Plugin\Customer\Model\Address&quot;/&gt;
  &lt;/type&gt;
  </code></pre>