On the checkout page, I wish to load a form on a modal whose data depends on the uc_addresses select address drop-down.

I have declared a form through hook_form and add the form to the checkout page through mymodule_form_uc_cart_checkout_form_alter:

  $form['panes']['delivery']['modal'] = drupal_get_form('form_id');

My question is: how will I rebuild the form when a different drop-down option is selected? Note that I have tried to add a parameter in hook_form:drupal_get_form('form_id', 'address_id') my problem is the form rebuild when the option is changed.


You could possibly use the #states API to react upon another option in the dropdown is selected, this will work without submits on the client side.

If you want to change your form after submission has happened only you'd have to add conditions in your custom form function that will change your form dynamically according to what is contained in the $form_state['values'] of that dropdown field.

  • Where from the rebuild will be triggered and how? Unfortunately I couldn't add a second callback to $form['panes']['delivery']['select_address'] without messing up the functionality. – D3v Jan 29 '18 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.