Closed (fixed)
Project:
Ubercart
Version:
7.x-3.0
Component:
Cart/checkout
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
13 Aug 2013 at 08:42 UTC
Updated:
27 Aug 2013 at 15:01 UTC
I have to alter cities form field in checkout page under delivery section. I have to change it from a textfield to select options dropdown
I have managed to do that using a separate template file for checkout page but by that i
am not able to use #ajax functionality of form field
In D6 it was possible using hook_form_uc_cart_checkout_form_alter But in D7 the address fields are rendered in a diff way and i'm not able to alter the address form fields as desired
what are other ways of changing it ?
Comments
Comment #1
longwaveSupport requests are never critical.
To alter the address fields, you have two options: you can use hook_element_info_alter() to change the #process callback of all address form elements, or you can use hook_form_alter() to add an #after_build callback to the checkout form only, where you should be able to change the city field.
Comment #2
mahimajulka commentedHi,
i used
hook_form_uc_cart_checkout_form_alterbut here delivery city field cant be accessed for changingi get access to $form['panes']['delivery']['address'] which has keys
#type
#default_value
#key_prefix
#prefix
#suffix
The problem is that delivery_city form field is not getting accessed from here.
In D6 i used this function for form alteration.
Also, regarding using hook_element_info_alter()
i believe this is to change definition of a type. I want city to change from a text field to a select options form variable.
Comment #3
mahimajulka commentedHi,
Please refer to the comment below.
the issue is still not resolved
Comment #4
hi.chawla commentedHi Longwave
Thanks for your reply. Please have a look at the MahimaJulka's reply. We are not able to get hold on to exact fields in the form.
Comment #5
longwavePlease read what I said in #1.
hook_element_info_alter() will let you change the definition of the uc_address type across the entire site. hook_form_alter() with an #after_build callback will let you change it in one specific place.
Comment #6
mahimajulka commented@longwave
i used hook_form_alter() with an #after_build callback
i was able to change the field from text field to select option .. thanks for this
but the #ajax parameter attached to this is not working.
it seems #ajax callbacks are attached with the hooks at an early stage.
is there any way to have the #ajax tag working ?
ps:
i was able to do this at the template level of checkout page as well.
Over there also i faced the same issue of #ajax not working.
i resorted to using jquery to link select option onchange event to an ajax call.
but im still looking for a better solution.
Comment #7
longwaveYou could perhaps try #process instead of #after_build, attaching it either to the full form or just the address element; if that doesn't work you will have to replace the entire element #process callback with hook_element_info_alter() instead.
Comment #8
mahimajulka commented@longwave
This is how it worked finally
thanks for all the help