Posted by kkaefer on February 20, 2010 at 12:30pm
NOTE: This module doesn't do anything of its own. Only install this module if another module requires it.
Table module allows you to create tables directly from the Forms API without having to write a custom theme function, like this:
<?php
$form['mytable'] = array(
'#type' => 'table',
'#empty' => t('There are no elements.'),
'#header' => array(t('ID'), t('Value')),
);
$items = db_query('SELECT id, value FROM {mytable}')->fetchAllKeyed();
foreach ($items as $id => $value) {
// Add a table row for each item.
$form['mytable'][] = array(
array('#type' => 'markup', '#markup' => check_plain($id)),
array('#type' => 'markup', '#markup' => check_plain($value)),
);
}
?>- Children’s
#typevalues don’t have to be set; they are automatically derived from the nesting. - If a row contains another form element directly, that form element is wrapped into a cell automatically.
- Array keys are used as HTML IDs automatically
- Attributes are copied to the table cell or row automatically.
Downloads
Project Information
- Maintenance status: Unsupported
- Development status: Obsolete
- Module categories: Developer, Theme Enhancements, Utility
- Reported installs: 5 sites currently report using this module. View usage statistics.
- Downloads: 261
- Last modified: February 27, 2011