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 #type values 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


Maintainers for Table

  • kkaefer - 3 commits
    last: 3 years ago, first: 3 years ago

Issues for Table

To avoid duplicates, please search before submitting a new issue.
All issues
Bug reports
Statistics (2 years)
New issues
Open bugs
Participants
nobody click here