[development] form_api: same form called multiple times, wrong form_state values

Lee Rowlands leerowlands at rowlands-bcs.com
Sun Mar 14 22:26:04 UTC 2010


Hi Hans
When you inspect the form using firebug/web developer toolbar - what form
id/form build id does each form have?
If they are all the same then you've got a problem and you might need to
use hook_forms. This is how (for example) Ubercart adds an 'add to cart'
button for multiple products on one page (ie multiple forms per page).
These 'add to cart' forms sound similar to yours - ie a button. Perhaps if
you have a look at how uc_product_forms works you might be able to do
something similar (http://api.lullabot.com/uc_product_forms)
Lee
On Sat, 13 Mar 2010 14:53:26 +0100, Hans Langouche

> I have a small admin form (2 buttons and a hidden value) that is 
> repeated multiple times (each time the value is different).
> 
> Now whenever I access $form_state['values'] from the submit function, 
> the hidden value always returns the data from the first form.  When I 
> print out $_POST directly I do get the correct data.
> 
> I've been searching this and it seems this is because the form_state is 
> cached.  I couldn't find any workaround though, so for the moment 
> working with $_POST.  Anyone know the correct way to do this ?
 



More information about the development mailing list