Hi,
I'm trying to display multiple instances of the same form on one page, where # of instances may vary. Right now I'm building the form via a for loop, which displays fine [see below]. However, I don't know how to let my submission handler function know which submit button was clicked, because mymodule_form_submit takes in the entire $form element but not $form_id.
Does anyone know how to tell the submission handler function which submit button was clicked?
for ($i=0; $i<$count; $i++) {
$form[$i]['formid'] = array(
'#type' => 'value',
'#value' => $i,
);
$form[$i]['request_approve'] = array(
'#prefix' => '
'#suffix' => '
',
'#type' => 'submit',
'#value' => t("Approve"),
'#submit' => array('mymodule_form_submit'),
);
}
Thanks,
Lilly
Comments
A simple solution is to
A simple solution is to create a variable that changes value for each loop.
eg: $form['form_id'] = array('#type' => 'value', '#value' => 'form_'.$i);
or better still change this:
'#value' => t("Approve_".$i),
You can test for either of these in the submit function.