I've been search results for hours but cannot find an answer to my problem.
I want to show a list using theme("table",...); inside my table, there's a column of buttons, which each functions as deleting the record for this row. Therefore, I did something like this:
foreach($person_list as $pyid => $record){
$render_ele = array('remove'.$pyid => array(
'#type' => "submit",
"#value"=> "remove",
'#submit' => array('shms_cca_form_remove_person_from_group'),
"#limit_validation_errors" => array(),
"#attributes" => array("pyid" => $pyid,'action' => "remove"),
));
$rows[] = array(
$record['full_name'], // full name
$record['matric_no'], // matric no
$record['room_number'], // room number
$record['position_name'],
is_numeric($record['cca_points'])?$record['cca_points']:"Not Assigned Yet",
drupal_render_children($render_ele),
);
};
However, when I clicked on the button, the submit function I've defined is not called (it called the default submit function instead).
When I try to add another default button into my form like this:
$form += array(
'nani' => array(
'#type' => "submit",
"#value"=> "remove",
'#submit' => array('shms_cca_form_remove_person_from_group'),
"#limit_validation_errors" => array(),
),
Both this button and my old-not-functioning submit button works.
I therefore conclude that it's a JavaScript problem... possibly some JavaScript is not included when I call the drupal_render by myself.
Could anyone help on how to solve this problem? Thanks a lot.
Update: I called drupal_render, because I want to pass the rendered result to rows[] so that I can put these elements inside a table, like this:
$render_ele = array('remove'.$pyid => array(
'#type' => "submit",
"#value"=> "remove",
'#submit' => array('shms_cca_form_remove_person_from_group'),
"#limit_validation_errors" => array(),
"#attributes" => array("pyid" => $pyid,'action' => "remove"),
));
$rows[] = array(
$record['full_name'], // full name
$record['matric_no'], // matric no
$record['room_number'], // room number
drupal_render($option),
);
return array(
"person_list" => array(
'#type' => 'fieldset',
"#title"=> t("Group Members"),
'#collapsible' => TRUE,
"#collapsed" => FALSE,
"#children" => theme("table",array('header'=>$header,"rows"=>$rows)).$add_member_str,
'#weight' => 10,
),
);