1

For right now I need to return a themed table, a form, & content on one page. In my page callback function how do I properly store and return this variable/array?

I looked at the page below, but the code did not seem to work properly. I can only get the themed table (first in array) to show, but nothing else after it.

Return both a form and content in a menu callback

EDIT:

i tried the code below for my return, but it doesn't work. $header & $rows are both properly declared and holding the right data.

return array(
  'my_content' => array(
    '#type' => 'markup',
    '#markup' => 'Some markup',
  ),
  'my_table' => theme('table', array('header' => $header, 'rows' => $rows)),
);
  • it seems like only the first item in my array will display then nothing else. works the same whether i'm using forms, tables, and/or just markup. – Dave_R May 9 '12 at 22:46
  • Could you post the code you're having trouble with? – Clive May 10 '12 at 8:32
  • ok edited the main question. – Dave_R May 11 '12 at 0:47
1

Remember that theme('table'.. returns HTML markup, so you are assigning a HTML string to the my_table key. In the example you linked drupal_get_form was being used which returns a renderable array, so it would have functioned correctly. Since render() doesn't know what to do with an HTML string, you must pass the render function the information before it has been turned into HTML:

return array(
  'my_content' => array(
    '#type' => 'markup',
    '#markup' => 'Some markup',
  ),
  'my_table' => array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
  ),
);
  • Thanks for the answer I'll fix up my code sometime today. – Dave_R May 11 '12 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.