If blank, address State is Alabama and Zip is 0 - PATCH SUBMITTED

mjwest10 - June 25, 2007 - 16:15
Project:Address field for CCK
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:rconstantine
Status:closed
Description

If a user does not specify a state or a zip in the address field Alabama is stored as the state and 0 as the zip code.

Steps to reproduce:

  1. Create a CCK Address field for a content type
  2. Create a new instance of that content type
  3. Leave the address field blank and submit the content
  4. Edit that instance of the content again
  5. Notice how the state is Alabama and the Zip code is 0
  6. If you try to submit the content again it will error because 0 is not a valid zip

How To Fix:
Add a new row to the cck_address_states table, that has a state ID of 0 a blank state_name and state_abbrv and a country code of US.

Apply the patch attached with this thread.

AttachmentSize
cck_address.module_1.patch508 bytes

#1

rconstantine - June 25, 2007 - 21:01

Hmm, first, I see that this issue is opened for version 1.0, which is not the latest version. You'll notice on the project page that the very first words in the description are USE THE DEV VERSION. So double check and make sure this isn't fixed in that version, or modify the version of this issue if that's what you've got.

Second, what you describe should only be happening at all if you REQUIRED that users fill in an address. I have several content types created without the address being required that do not break as you've described. Please confirm whether you have checked the REQUIRED box during content type creation.

Third, if you did REQUIRE the field, then a user should be filling in an address and since ALABAMA is the default, it would naturally be selected if the user didn't change it. If empty zips ARE being stored as 0 in the dev version, then I'll have to find out why. I'd rather not store it that way in the first place than unset the variable as you did in your patch.

So please confirm EACH of my questions above so I can proceed.

Thank you.

#2

mjwest10 - June 26, 2007 - 15:43
Version:5.x-1.0» 5.x-1.x-dev

Sorry about that - you are right I was using the wrong version. I uninstalled it and installed the latest one. That fixed the zip being stored as 0 problem - it is now being stored as an empty string so thats good. However, it is still selecting Alabama as the default state - and I've double checked and I haven't checked the required option for the field. I even tried creating a new field and making sure the required box was not checked. I will now look at the code and see if I can figure anything out. Hope this helps and again sorry I didn't notice that I should use the DEV version.

#3

mjwest10 - June 26, 2007 - 16:11

I checked the code and I couldn't find where you were handling if the user didn't check the required field. I also thought of one more thing - I am selecting that states should be displayed with Select with Fullname. At anyrate, one solution is to change the cck_address_get_states function to add a blank option if the user did not say the field is required. I submitted a patch for this. If I am totally missing something again I am sorry - please know I am trying to be helpful and not just complain, but I am just learning PHP so sorry if I miss something. Thank you for a great module that is very helpful to me.

AttachmentSize
cck_address.module_2.patch554 bytes

#4

rconstantine - June 26, 2007 - 16:28
Assigned to:Anonymous» rconstantine

No need to apologize for anything. If you take the time to read past issues for this module (as well as my other modules), I think you'll find that I welcome any relevant issue that will make my module better. I am working on an overall project that requires all modules work as expected. So I have released my modules in the hopes that by the time I need to go live, all bugs will be worked out.

I'll review your patch and latest observations and see what can be done.

#5

rconstantine - July 3, 2007 - 02:33
Status:active» fixed

Okay, I fixed this such that upon submission, the street1, city, and zip fields are checked to see if ALL are empty. If so, then all other fields are made empty and saved that way. Then, if all fields are empty when you view the node, the address field simply isn't shown.

#6

rconstantine - July 9, 2007 - 19:07
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.