How do I add a custom table to a form in another module in Drupal?
I am trying to make a module to add a table to a form in anoth开发者_StackOverflower module. I found I can add the new data in a module_form_alter hook but how to I get it to run through a theme hook? The module I am trying to modify has a theme hook for the page I want to modify. I don't want to change the original form I just want to add a table with new data below it. Thanks
Arrange your data into table headers and cell rows, and return the output with
return theme('table', $header, $rows, array('class' => 'ifyouwantaclassname'));
That will return data themed in a table. $rows are constructed by looping the dataset and adding an array item.
But you also need to change the structure of the form with a theme hook.
http://www.akchauhan.com/create-drupal-form-using-theme_table-like-module-list-form/
Has a pretty good write up on how to do it.
精彩评论