diff --git a/tablefield.module b/tablefield.module
index 201d57fd..d04dd578 100644
--- a/tablefield.module
+++ b/tablefield.module
@@ -2451,10 +2451,12 @@ function theme_tablefield($variables) {
         // Build row.
         $output .= ' <tr' . drupal_attributes($attributes) . '>';
         $i = 0;
-        foreach ($cells as $cell) {
-          $cell = tablesort_cell($cell, $header, $ts, $i++);
-          $output .= _theme_table_cell($cell, ($header_orientation === 'Both' || $header_orientation === 'Vertical') && $i == 1);
-          $i++;
+        if (is_array($cells)) {
+          foreach ($cells as $cell) {
+            $cell = tablesort_cell($cell, $header, $ts, $i++);
+            $output .= _theme_table_cell($cell, ($header_orientation === 'Both' || $header_orientation === 'Vertical') && $i == 1);
+            $i++;
+          }
         }
         $output .= " </tr>\n";
       }
