1

So for some reason my Magento install (1.5) stopped saving new customers state/region name, both inside admin and outside.

Magento's registration form has a dropdown select, with a name of "region_id" and a hidden text field named "region". I guess that some javascript is supposed to get the selected name and set the "region" field, but that doesn't work.

What I did was create a jQuery line that, on form submit, gets the region name and sets the "region" field to it. That works, somewhat. There are still customers who are registering without a region name, only the id.

Anyone ever had something similar?

David Manners
  • 27,241
  • 9
  • 76
  • 220
localhost
  • 131
  • 2
  • 12

1 Answers1

2

There is a table customer_form_attribute which links the customer and customer address attributes to the forms in your website. There should be an entry in this table for the attribute region_id. Note: in the sample data this is attribute_id 13.

Without this entry the attribute will not be saved when the form is processed. The attribute will not be picked up when the extractData in the class Mage_Customer_Model_Form and so it will be ignored when extracting the data from the request into the $addressData.

/app/code/core/Mage/Customer/controllers/AddressController.php

$addressForm = Mage::getModel('customer/form');
$addressForm->setFormCode('customer_address_edit')
    ->setEntity($address);
$addressData    = $addressForm->extractData($this->getRequest());
$addressErrors  = $addressForm->validateData($addressData);
if ($addressErrors !== true) {
    $errors = $addressErrors;
}
Fabian Blechschmidt
  • 35,388
  • 8
  • 75
  • 182
David Manners
  • 27,241
  • 9
  • 76
  • 220