You are here

function theme_workflow_notify_settings_form in Workflow 7

Same name and namespace in other branches
  1. 7.2 workflow_notify/workflow_notify.pages.inc \theme_workflow_notify_settings_form()

Theme the settings form.

File

workflow_notify/workflow_notify.admin.inc, line 154
Admin UI to Notify roles for Workfllow state transitions.

Code

function theme_workflow_notify_settings_form($variables) {
  $form = $variables['form'];
  $output = '';
  $table_id = 'workflow-notify-settings';
  $output .= drupal_render($form['from_address']);
  $output .= drupal_render($form['filter']);
  $output .= drupal_render($form['tokens']);
  $table = array(
    'rows' => array(),
    'header' => array(),
    // To be filled in.
    'attributes' => array(
      'id' => $table_id,
      'style' => 'width: 100%; margin-top: 1em;',
    ),
  );
  $columns = $form['#columns'];
  $colspan = count($columns);
  foreach ($columns as $field => $title) {
    $table['header'][] = $title;
  }

  // Iterate over each element in our $form['states'] array
  foreach (element_children($form['states']) as $id) {

    // We are now ready to add each element of our $form data to the rows
    // array, so that they end up as individual table cells when rendered
    // in the final table.
    $row = array();
    foreach ($columns as $field => $title) {
      $row[] = array(
        'data' => drupal_render($form['states'][$id][$field]),
        'class' => array(
          drupal_html_class($field),
        ),
      );
    }

    // Put the data row into the table.
    $table['rows'][] = array(
      'data' => $row,
    );
  }
  $output .= theme('table', $table);
  $output .= drupal_render($form['explain']);

  // And then render any remaining form elements (such as our submit button)
  $output .= drupal_render_children($form);
  return $output;
}