title: Magento - Extra Address Fields (during registration)
body: <p>At customer registration:</p>
  <p>By default, Magento uses the supplied customer name to auto-populate the default shipping / billing information. We are a B2B, and need to gather that information separately at the time of registration. Additionally, we need to get the address fax number.</p>
  <p>These are not custom attributes (already made a bunch of those, and have integrated them into a greatly expanded registration form), but the <strong>standard</strong> first name, last name and fax fields associated with a customer address.</p>
  <p>I've attempted this:</p>
  <pre><code>        &lt;span class=&quot;msg&quot;&gt;Default shipping and billing information.&lt;/span&gt;
          &lt;ul class=&quot;form-list&quot;&gt;
              &lt;li class=&quot;fields&quot;&gt;
                  &lt;div class=&quot;field billing_name&quot;&gt;
                      &lt;label for=&quot;billing_firstname&quot; class=&quot;required&quot;&gt;&lt;em&gt;*&lt;/em&gt;&lt;?php echo $this-&gt;__('First Name') ?&gt;&lt;/label&gt;
                      &lt;div class=&quot;input-box&quot;&gt;
                          &lt;input type=&quot;text&quot; name=&quot;billing_firstname&quot; id=&quot;billing_firstname&quot; value=&quot;&lt;?php echo $this-&gt;htmlEscape($this-&gt;getFormData()-&gt;getFirstName()) ?&gt;&quot; title=&quot;&lt;?php echo $this-&gt;__('First Name') ?&gt;&quot; class=&quot;input-text required-entry&quot; /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;field billing_name&quot;&gt;
                      &lt;label for=&quot;billing_lastname&quot; class=&quot;&quot;&gt;&lt;em&gt;*&lt;/em&gt;&lt;?php echo $this-&gt;__('Last Name') ?&gt;&lt;/label&gt;
                      &lt;div class=&quot;input-box&quot;&gt;
                          &lt;input type=&quot;text&quot; name=&quot;billing_lastname&quot; id=&quot;billing_lastname&quot; value=&quot;&lt;?php echo $this-&gt;htmlEscape($this-&gt;getFormData()-&gt;getLastName()) ?&gt;&quot; title=&quot;&lt;?php echo $this-&gt;__('Last Name') ?&gt;&quot; class=&quot;input-text required-entry&quot; /&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/li&gt;
  </code></pre>
  <p>but I'm not clear what the input name should be. Whatever the case, the account names are used instead.</p>
  <p>Looking for a little information on maybe the &quot;name&quot; of the form fields required, and some method of disabling the auto-populate feature, should that also be required.</p>
  <p>cheers</p>
  <hr>
  <h3>Update</h3>
  <p>Looking at this a little more closely.</p>
  <p>I'm overriding the <strong>mage/customer/controller/accountController.php :: createPostAction()</strong> and I see in the controller the location where the form is processed and populated as a customer entity.</p>
  <p>I'm trying something like this</p>
  <pre><code>   if ($this-&gt;getRequest()-&gt;getPost('create_address')) {
          /* @var $address Mage_Customer_Model_Address */
  
          $address = Mage::getModel('customer/address');
  
          /* @var $addressForm Mage_Customer_Model_Form */
  
          $addressForm = Mage::getModel('customer/form');
          $addressForm-&gt;setFormCode('customer_register_address')
              -&gt;setEntity($address);
  
          $addressData    = $addressForm-&gt;extractData($this-&gt;getRequest(), 'address', false);
          $addressErrors  = $addressForm-&gt;validateData($addressData);
          if ($addressErrors === true) {
              $address-&gt;setId(null)
                  -&gt;setIsDefaultBilling($this-&gt;getRequest()-&gt;getParam('default_billing', false))
                  -&gt;setIsDefaultShipping($this-&gt;getRequest()-&gt;getParam('default_shipping', false));
              $addressForm-&gt;compactData($addressData);
  
  
              // attempting to jam vars into address obj
                  $address['_data']['firstname'] = $this-&gt;getRequest()-&gt;getPost('billing_firstname');
                  $address['_data']['lastname'] = $this-&gt;getRequest()-&gt;getPost('billing_lastname');
                  $address-['_data']['fax'] = $this-&gt;getRequest()-&gt;getPost('billing_fax');
              // end 
                  Mage::log('createPostAction, after var jam: '. print_r($address, true ) );
  
  
              $customer-&gt;addAddress($address);
  
              $addressErrors = $address-&gt;validate();
              if (is_array($addressErrors)) {
                  $errors = array_merge($errors, $addressErrors);
              }
          } else {
              $errors = array_merge($errors, $addressErrors);
          }
      }
  </code></pre>
  <p>When i log this out:</p>
  <pre><code>2012-12-18T01:51:10+00:00 DEBUG (7): createPostAction, after var jam: Mage_Customer_Model_Address Object
  (
      [_customer:protected] =&gt; 
      [_eventPrefix:protected] =&gt; customer_address
      [_eventObject:protected] =&gt; customer_address
      [_resourceName:protected] =&gt; customer/address
      [_resource:protected] =&gt; 
      [_resourceCollectionName:protected] =&gt; customer/address_collection
      [_cacheTag:protected] =&gt; 
      [_dataSaveAllowed:protected] =&gt; 1
      [_isObjectNew:protected] =&gt; 
      [_data:protected] =&gt; Array
          (
              [entity_type_id] =&gt; 2
              [entity_id] =&gt; 
              [is_default_billing] =&gt; 1
              [is_default_shipping] =&gt; 1
              [firstname] =&gt; Chirp  // customer firstname
              [lastname] =&gt; Anaplex // customer lastname
              [company] =&gt; some agency
              [street] =&gt; 2345 somewhere dr
              [city] =&gt; somecity
              [country_id] =&gt; US
              [region] =&gt; 
              [region_id] =&gt; 44
              [postcode] =&gt; 84151
              [telephone] =&gt; 123-123-1233
          )
  
      [_hasDataChanges:protected] =&gt; 1
      [_origData:protected] =&gt; 
      [_idFieldName:protected] =&gt; entity_id
      [_isDeleted:protected] =&gt; 
      [_oldFieldsMap:protected] =&gt; Array
          (
          )
  
      [_syncFieldsMap:protected] =&gt; Array
          (
          )
  
  )
  </code></pre>
  <p>The form variables are getting passed successfully ( i see them in the log ), but I seem to be unable to insert them into the address object this way. I get the following Notice:</p>
  <pre><code>2012-12-18T16:39:39+00:00 ERR (3): Notice: Indirect modification of overloaded element of Mage_Customer_Model_Address has no effect  in /root/namespace/module/controllers/AccountController.php on line 79
  </code></pre>
  <p>If this is &quot;Indirect&quot; - what is the &quot;Direct&quot; method?</p>
  <p>Anyone?</p>