I think you want to manage multiple submit buttons associated with their data to perform operations on it.
The better approach is to use check boxes with a single submit button.
e.g.
function my_form(){
$data_ids = array();
foreach($data_set as $data){
$data_ids[$data] = '';
$form['data']['data_preview'][$data['id']] = array('#value' => $data['value']);
}
$form['selection'] = array(
'#type' => 'checkboxes'
'#options' => $data_ids;
);
$form['process'] = array(
'#type' => 'submit',
'#value' => 'do',
);
$form['#theme'] = 'my_form';
}
Theme handler (do not forget to implement my_form
entry in hook_theme
)
function theme_my_form($form = array()){
$rows = array();
foreach(element_children($form['selection']) as $id) {
$fields = array();
$fields[] = drupal_render($form['selection'][$id]);
$fields[] = drupal_render($form['data']['data_preview'][$id]);
$rows[] = $fields;
}
$output = theme('table', array('Select', 'Data'), $rows);
$output .= drupal_render($form);// Render rest of form
return $output;
}
Now form submit handler
function my_form_submit(&$form, $form_state){
$clicked_button = $form_state['clicked_button']['#value'];
$values = $form_state['values'];
if ($clicked_button == $values['process']){
//Here check $value['selection'] array and process accordingly
}
}