<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hey all,<br>
<br>
the html form id's are different (the id has a different number
postfixed for each form) and the form_build_id (hidden value) are also
different. The form itself gets called with the same form_id every
time.<br>
<br>
I hadn't heard about hook_formS yet though, and it seems like the
answer lies there :-). So I'll definitely look into that.<br>
<br>
Tnx for the input all,<br>
<br>
HnLn<br>
<br>
<br>
<br>
<br>
Randy Fay wrote:
<blockquote
cite="mid:15c957091003141604x5c30e76ew36fb8cf2e2ba0b37@mail.gmail.com"
type="cite">Amazon Store has to do this:<br>
<br>
<span style="font-family: courier new,monospace;">function
amazon_store_forms($form_id) {</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $args =
func_get_args();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $forms = array();</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if
(strpos($form_id, 'amazon_store_addcart_form') === 0) {</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
$forms[$form_id] = array(</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'callback'
=> 'amazon_store_addcart_form',</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'callback
arguments' => $args[1],</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> );</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if
(strpos($form_id, '_amazon_store_cart_quantity_form') === 0) {</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
$forms[$form_id] = array(</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'callback'
=> '_amazon_store_cart_quantity_form',</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'callback
arguments' => $args[1],</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> );</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> return $forms;</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br>
<br>
<br>
Then instead of just drupal_get_form('form_id'), you have to do
drupal_get_form('form_id_plus_key'), if I remember right.<br>
<br>
-Randy<br>
<br>
<br>
<div class="gmail_quote">On Sun, Mar 14, 2010 at 4:46 PM, Greg
Knaddison <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:Greg@growingventuresolutions.com">Greg@growingventuresolutions.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div class="h5">On Sat, Mar 13, 2010 at 6:53 AM, Hans Langouche<br>
<<a moz-do-not-send="true" href="mailto:hans.langouche@gmail.com">hans.langouche@gmail.com</a>>
wrote:<br>
> I have a small admin form (2 buttons and a hidden value) that is
repeated<br>
> multiple times (each time the value is different).<br>
><br>
> Now whenever I access $form_state['values'] from the submit
function, the<br>
> hidden value always returns the data from the first form. When I
print out<br>
> $_POST directly I do get the correct data.<br>
><br>
> I've been searching this and it seems this is because the
form_state is<br>
> cached. I couldn't find any workaround though, so for the moment
working<br>
> with $_POST. Anyone know the correct way to do this ?<br>
<br>
</div>
</div>
I ran into this a while ago myself. You have to do a little trickery<br>
with the form_id value so that each form on the page has a unique ID.<br>
If the forms are for users then maybe the UID will work. If they are<br>
for node teasers maybe the node ID. Then you create a hook_forms value<br>
that gets called and resets the callback to be a specific general<br>
function.<br>
<br>
See <a moz-do-not-send="true"
href="http://api.drupal.org/api/function/hook_forms" target="_blank">http://api.drupal.org/api/function/hook_forms</a>
and perhaps some of<br>
the modules which use it like fivestar.module and<br>
notifications_ui.module (I think that one does...one of the<br>
notifications/messaging modules does).<br>
<br>
Please ask if you need more advice - it's a tricky problem to resolve<br>
that cost me more time than I'd like to admit.<br>
<br>
Regards,<br>
Greg<br>
<font color="#888888"><br>
--<br>
Greg Knaddison | 303-800-5623 | <a moz-do-not-send="true"
href="http://growingventuresolutions.com" target="_blank">http://growingventuresolutions.com</a><br>
Mastering Drupal - <a moz-do-not-send="true"
href="http://www.masteringdrupal.com" target="_blank">http://www.masteringdrupal.com</a><br>
</font></blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
Randy Fay<br>
Drupal Development, troubleshooting, and debugging<br>
<a moz-do-not-send="true" href="mailto:randy@randyfay.com">randy@randyfay.com</a><br>
+1 970.462.7450<br>
<br>
</blockquote>
</body>
</html>