You are here

function theme_notifications_table_form in Notifications 7

Same name and namespace in other branches
  1. 6.4 notifications.pages.inc \theme_notifications_table_form()
  2. 6 notifications.admin.inc \theme_notifications_table_form()
  3. 6.2 notifications.admin.inc \theme_notifications_table_form()
  4. 6.3 notifications.admin.inc \theme_notifications_table_form()

Generic table formatting for forms

File

./notifications.pages.inc, line 460
User pages for Notifications

Code

function theme_notifications_table_form($variables) {
  $form = $variables['form'];
  $output = '';

  // Get table information from special form properties
  $index = !empty($form['#table_index']) ? $form['#table_index'] : $form['#table_fields'][0];
  $header = !empty($form['#table_header']) ? $form['#table_header'] : array();
  foreach (element_children($form[$index]) as $key) {
    $row = array();
    foreach ($form['#table_fields'] as $field) {
      $row[] = drupal_render($form[$field][$key]);
    }
    $rows[] = $row;
  }
  if ($rows) {
    $output .= theme('table', array(
      'header' => $header,
      'rows' => $rows,
    ));
  }
  else {
    $output .= '<p>' . t('No elements') . '</p>';
  }
  $output .= drupal_render($form);
  return $output;
}