Module Monday: TableField

Add data tables to a Drupal content type with less hassle

Drupal's custom fields allow site builders to tweak out their content types with all kinds of data: phone numbers, file uploads, maps, and more. When it comes to tabular information, though, most of us fall back on simple HTML tables in the body field. The TableField module aims to fix that by storing and editing data tables with a single consolidated Drupal field type.

Tablefield widget

Once added to a content type, Table Fields allow content creators to enter simple values into a grid of form fields -- populating a table that's ultimately saved as a single field on the node. If they already have an existing CSV file, like data exported from Excel, it can be uploaded directly into the field without manually entering each cell. The resulting information is displayed using Drupal's standard table theming functions, so the data will match the look and feel of the rest of the site. Visitors can also be given a "download" link to grab a CSV copy of the table data directly.

Tablefield display settings

Although it's simple to set up and relatively easy to use, there are a couple of hitches. There's an outstanding bug that makes its fields impossible to edit if you're running Drupal 7.25, although a patch has been posted to fix the problem. In addition, large tables with hundreds of rows and columns can generate editing errors that are difficult to recover from. However, if you're looking to expose small-to-medium sized data sets as part of a Drupal content type and need the data to be editable from Drupal's node forms, TableField could be just the trick.

You can also watch the (non-free) Drupalize.Me Tablefield tutorial video.

Get in touch with us

Tell us about your project or drop us a line. We'd love to hear from you!