Community

create a dynamic form from database results in drupal 7

How can we theme a form in drupal 7 from the database result set?

I have a table structure with the following fields, event_id, event_title, event_date. I created a form to insert data to that table. Now i wanted to show the results as table format to edit. We can use "tableselect" theme to show checkbox on each row and upon submit we can redirect the form to edit form. But i want to show the results as table format along with some html controls.

For example, event id with check box, event title with textfield, and event date with date_popup control for each rows.

Please provide some sample code to theme dynamic form with these controls. So that i can edit all rows values in one page and i can submit that page to save the updated data.

Thanks in advance.

Comments

Some hints

I don' t have a direct answer to this, but here are some hints:
- If you can get your hand on the book 'Definitive Guide to Drupal 7', there is an example of "Displaying Data in a Sortable Table" in Chapter 19.
http://definitivedrupal.org/
- This book comes with a downloadable module example, available here:
http://drupal.org/project/xray
- See also the Examples modules for practical examples of the database API.
http://drupal.org/project/examples