1

I try to create a table where a row is looking like this:

|Text1|Text2|Button1|

As soon as the user clicks on the button I want to exchange the Button1 with tow textFields and another button... so a normal AJAX-request. I've tried to implement this, not sure if this is the correct way, let me know if I could to it in a completely other way :S

So what I've already done: In my hook_menu i link to a function that returns the data:

return theme ( 'my_theme_function', array (
                    'running' => true, 
                    'form' => $database->getData ()
            ) );

What happens in the getData()-Function: I create the form using drupal_get_form(..).. returned from the given form is this:

$data = array (
                    'items' => $finder->getGamesToPlayForm ( $form_state ), 
                    '#title' => 'Title'
            );

the $finder returns the list of items I want to show in the table. So nothing special.

my_theme_function is set to use a template-file where I would like to show the whole stuff. This looks like this:

$header = array (
        'Col1', 
        'Col2', 
        '' 
);

$rows = array ();

foreach ( element_children ( $formData ['items'] ) as $gameId ) {
    $row = array ();
    $row [] = drupal_render ( $formData ['items'] [$gameId] ['#col1'] );
    $row [] = drupal_render ( $formData ['items'] [$gameId] ['#col2'] );
    $row [] = drupal_render ( $formData ['items'] [$gameId] ['#form'] );
    $rows [] = $row;
}
$output = theme ( 'table', array (
        'header' => $header, 
        'rows' => $rows 
) );

unset($formData['items']);


$output .= drupal_render_children ( $formData );

print $output

this way, everything is printed correct. But there are no "form"-tags, which stops my form from working..

So, any idea/hint how to solve this kind of problem? Probably I'm on the completely wrong way..

Stefan
  • 1,007
  • 1
  • 11
  • 32
  • everything seems ok but I don't get what you mean by `But there are no ""-tags` – Marius Ilie Nov 17 '11 at 10:19
  • this should be "form"-tags :P For now, i removed all this stuff and added the table-stuff in the prefeix and postfix.. this works quite well... – Stefan Nov 19 '11 at 07:56

1 Answers1

0

try

'render element' => 'form'

in your theme

Pan Chrono
  • 420
  • 3
  • 16