Fieldgroup Table module extends the Field Group module and provides a "Table" group format, which renders the fields it contains in a table. The first column of the table contains the field labels and the second column contains the rendered fields. See an example in the screenshot below.

Screenshot of Field Group Table

The module page contains basic configuration instructions.

Removing empty rows from the table

Sometimes the table is showing empty rows because different formatters render their output differently. To give site builders full control, the module includes hook_field_group_table_rows_alter which you can implement in your own module and then remove the unwanted rows.

Example of hook_field_group_table_rows_alter

On my site, normal text fields and email fields were sometimes printing an empty row to the table. It turned out that the reason for this was an empty '#markup' element. The following hook implementation removed the empty rows.

function YOURMODULE_field_group_table_rows_alter(&$element, &$children) {
  foreach ($children as $index => $child) {
    if (is_array($element[$child])) {
      if ($element[$child]['#formatter'] == 'text_default' || ($element[$child]['#formatter'] == 'email_spamspan')) {
        if ($element[$child][0]['#markup'] == NULL) {
          // This is an empty row, remove it
          unset($children[$index]);
          unset($element[$child]);
        }
      }
    }
  }
}

If you have more examples on hook implementations in different scenarios, please add them to this documentation by editing this page!

AttachmentSize
field-group-table.PNG25.14 KB