Amazon Store has to do this:
function amazon_store_forms($form_id) {
$args = func_get_args();
$forms = array();
if (strpos($form_id, 'amazon_store_addcart_form') === 0) {
$forms[$form_id] = array(
'callback' => 'amazon_store_addcart_form',
'callback arguments' => $args[1],
);
}
if (strpos($form_id, '_amazon_store_cart_quantity_form') === 0) {
$forms[$form_id] = array(
'callback' => '_amazon_store_cart_quantity_form',
'callback arguments' => $args[1],
);
}
return $forms;
}
Then instead of just drupal_get_form('form_id'), you have to do drupal_get_form('form_id_plus_key'), if I remember right.
-Randy
I ran into this a while ago myself. You have to do a little trickeryOn Sat, Mar 13, 2010 at 6:53 AM, Hans Langouche
<hans.langouche@gmail.com> wrote:
> 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 ?
with the form_id value so that each form on the page has a unique ID.
If the forms are for users then maybe the UID will work. If they are
for node teasers maybe the node ID. Then you create a hook_forms value
that gets called and resets the callback to be a specific general
function.
See http://api.drupal.org/api/function/hook_forms and perhaps some of
the modules which use it like fivestar.module and
notifications_ui.module (I think that one does...one of the
notifications/messaging modules does).
Please ask if you need more advice - it's a tricky problem to resolve
that cost me more time than I'd like to admit.
Regards,
Greg
--
Greg Knaddison | 303-800-5623 | http://growingventuresolutions.com
Mastering Drupal - http://www.masteringdrupal.com