Add/modify address field (zone)

Posts: 20
Joined: 03/22/2008
Bug Finder

Hi, I'm a bit confused and need some help.

For several reasons I don't like the dropdown-list style of zone in addresses, and would like to implement a state/region text field instead. I've found the first step in the forum, which is to write a hook_form_alter in my custom module, and that works fine, the new field appears on the checkout form. But what's next? How can I make sure it is used and displayed where needed? I have the database field and tried to play around with hook_order, but how to access the submitted form here? Or where to do what? (:

Thank you in advance for helping me out.

--

Tom Szigeti

Posts: 20
Joined: 03/22/2008
Bug Finder

After reading lots of code, I've found that it's impossible to do it gracefully, or I might have overlooked something, and please correct me if that is the case.

Now my next idea is to use my own checkout panes instead of the official ones. That would cause major redundancy, but it's a bit less of a problem than re-patching each release.

Damn, I wish someone comes up with a better idea cause my perfectionism doesn't like this workaround.

Tom

--

Tom Szigeti

Posts: 5617
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

So... I'm not sure it's impossible to do it gracefully. I just didn't have any good ideas earlier. Now I'm wondering if you can use hook_form_alter() to change those selects into textfields (and somehow remove the related JS? Puzzled) like you were... but then also add some sort of preprocessing to them. This way, before it gets to the checkout pane validation, you can check the text entered and change it to the numeric value that the checkout pane expects when it validates the selections.

I think you might have to do it by adding a custom submit handler to the form that gets called before the normal one... Puzzled

Posts: 20
Joined: 03/22/2008
Bug Finder

Thanks, that might be a better idea. My approach were to add a new text field, and that couldn't work because of the several hard-coded address field list, but adding a new line to the zone table on-the-fly with every submit might work. I will try it tomorrow. Thank you very much, will let you know the results.

Tom

--

Tom Szigeti

Posts: 20
Joined: 03/22/2008
Bug Finder

I'm sitting on the first place of the #submit queue, rewriting the form contents, but the order is stored before this happens. I tried to play again with hook_order, without any success. Any new ideas appreciated

TIA

--

Tom Szigeti

Posts: 5617
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Hmm... looks like that might be my bad. It appears you'll actually need to deal with the form values in the validate process. The problem is I'm not sure if you can safely manipulate the values in a validate handler. I guess it's worth a shot. Eye-wink