By Edward.H on
SOLVED!see my reply for details,thanks for cignex & netman
help!SOS! Could anyone help me out on themeing below dynamic forms within a table and all same delta forms must be within a same <tr> </tr>column,many many thanks in advance.
the table I want:
<table>
<tr>
<td>form[a] [0]</td>
<td>form[b] [0]</td>
<td>form[c] [0]</td>
<td>form[d] [0]</td>
</tr>
<tr>
<td>form[a] [1]</td>
<td>form[b] [1]</td>
<td>form[c] [1]</td>
<td>form[d] [1]</td>
</tr>
<tr>
<td>form[a] [2]</td>
<td>form[b] [2]</td>
<td>form[c] [2]</td>
<td>form[d] [2]</td>
</tr>
.....
</table>
codes:
function demo_abcd_form($form_state, &$node){
$delta=0;
for($delta=0;$delta<count($igdata);$delta++){
$form['a'][$delta]=array(
...
);
$form['b'][$delta]=array(
.....
);
$form['c'][$delta]=array(
.....
);
$form['d'][$delta] = array(
.....
);
}
return $form;
}
function demo_nodeapi(&$node, $op, $teaser=FALSE, $page=FALSE ){
......
switch ($op) {
case 'view':
$node->content['demo_form'] = array(
'#type'=>'fieldset',
'#title'=>'demo',
'#value' => '<table style="text-align: left; width: 100%;" border="1"
cellpadding="2" cellspacing="2" ><tbody>'.drupal_get_form('demo_abcd_form',$node).'</tbody-></table>',
'#weight' => -5,
);
break;
}
Comments
you can you theme_form hook
you can you theme_form hook to make a theme for form.
here you will find example http://drupal.org/node/36142
I solved
I'v solved this problem,I use below codes which I learned form the Userplus module. This is a really good example on theming dynamic forms for beginner like me:)