This may be a duplicate of the following: Multiple form submit, but I am unable to figure out how the answer applies to my situation. So here is my go at asking this (I admit) quite similar question:
I have a table with a row of data, each row has a submit button. It may look something like this:
$form['f'] = array();
foreach ($rows as $row) {
$form['f'][$row['nid']] = array();
$form['f'][$row['nid']]['nid'] = array(
'#markup' => $row['nid'],
);
$form['f'][$row['nid']]['submit'] = array(
'#type' => 'submit',
'#value' => t('sumbit'),
'#submit' => array('f_submit'),
);
}
I.e. the form consists of a sequence of rows, extracted from the database, I want to create a submit callback that picks up the value of the corresponding nid
field and prints out its value. I guess I am asking what to put where the comment below is.
function f_submit($form, &$form_state) {
// Here I want to print the value of the relevant nid field
}