I tried to add an address field for user in order to store user address. I made the field to 'required' and display in user registration form. There is no problem when I change the address in user profile form as state field update correctly based on the country selected. For example, select United State country will give a list of states for user to select. However, I found the state is not update when I enter address in user registration form. I tried all countries but the state and other fields remain the same even the ajax is called.
I tried to install address field in newly install Drupal but same problem happen in user register form. Can someone give a solution or opinion about this problem?
Comments
Comment #1
kinyik90 commentedComment #2
VSZ commentedI experience the same problem.
Does anybody has addressfield working on user registration page correctly?
Comment #3
iamEAP commentedThere are a bunch of reasons this can happen. I've opened an issue to solve this: #1861608: Prevent Drupal from caching pages with forms that include an address field widget
See this blog post for a full write-up, or just download the module to fix it here.
Comment #4
rszrama commentedThe issue here is that your registration form is being cached by Drupal (which it should never do, in my opinion). On its own this isn't normally a problem, but this results in form HTML being cached with a build ID that corresponds to data in your form cache after the #ajax request is run when the country changes. Subsequent requests to this page will then use that cached form data even though the form HTML is served from the cache, resulting in an inconsistent form.
The solution is to use the Cache Exclude module to prevent Drupal from caching user/register. I've tested this as working, and at this point I'm not sure we should do anything in Address Field to prevent the behavior. I will document this use of Cache Exclude, though, and the feature request to consider cache exclusion in this module can be found here: #1861608: Prevent Drupal from caching pages with forms that include an address field widget
Comment #5
VSZ commentedI have installed Cache Exclude module and excluded user/register from caching. Unfortunately it have not fixed the problem
I have finally found the module causing the problem. It was BOTCHA. As soon as I disabled it AddressField works correctly on registration form.