Tags/topics: 
1
Answers
Vote up!
0
Vote down!

Attach custom ajax to add to cart form?

Hi all,

I have a situation where I need to add a little custom ajax (eg. adding the '#ajax' array) to an add to cart form element for some specific display functionality, but when I look at the $form array from my hook_form_commerce_cart_add_to_cart_form_alter() I cannot actually access any of the line item form elements. For example one of them is rendered on the page as a select list, but I cannot find this anywhere in the $form array. It is like it is rendered into a proper Drupal form array afterwards or something.

The ['line_item_fields'] array is in there but it doesn't contain any of the normal form structure that you can modify with a hook_form_alter.

Can anyone shed some light on how I can pull this off?

Thanks!

Asked by: Ben Nunn
on July 18, 2014

1 Answer

Vote up!
0
Vote down!

Ok, I've just discovered hook_field_widget_form_alter() which seems to do what I'm looking for...

Answer by: Ben Nunn
Posted: Jul 18, 2014