DataTable

Component ID

1355428

Component name

DataTable

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

478

Component created

Component changed

Component body

Data Table is an addition to the core form API which allows the creation of a datatable field type. A data table is a draggable, sortable, table of data. Not only does it provide a table full of editable data, but also allows the developer to define a custom structure to display the data which taps directly into the form API. For example, rather than showing a grid full of text boxes, the developer can specify any of the normal form API elements to be used instead(ie: checkboxes, select lists, text areas, etc..)

Usage

$form['example'] = array(
  '#type' => 'datatable',
  '#draggable' => TRUE,
  '#limit' => 25, // Use 0 for unlimited
  '#structure' => array(
    array(
      '#type' => 'textfield',
      '#title' => t('Name'),
      '#default_value' => NULL,
    ),
    array(
      '#type' => 'select',
      '#title' => t('Favorite Color'),
      '#default_value' => 'red',
      '#options' => array(
        'red' => 'Red', 
        'green' => 'Green', 
        'blue' => 'Blue'
      ),
    ),
    array(
      '#type' => 'checkbox',
      '#title' => t('Likes Cats'),
      '#return_value' => 1,
      '#default_value' => 0,
    )
  ),
  '#value' => array(
    array('John Doe', 'green', 0),
    array('Lauren Ipsum', 'red', 1),
    array('Test', 'blue', 1),
  ),
);

Sponsorship

LevelTen Logo
This module is sponsored and developed by LevelTen Interactive. LevelTen is a full service interactive agency focused on building online brands by integrating digital strategy, Drupal development and internet marketing. Feel free to connect with us on Twitter and Facebook

If you would like to learn how to build smarter marketing websites with Drupal, checkout the Drupal Site Success! ebook