You are here

function theme_webform_emails_form in Webform 6.3

Same name and namespace in other branches
  1. 7.4 includes/webform.emails.inc \theme_webform_emails_form()
  2. 7.3 includes/webform.emails.inc \theme_webform_emails_form()

Theme the node components form. Use a table to organize the components.

Parameters

$form: The form array.

Return value

Formatted HTML form, ready for display.

File

includes/webform.emails.inc, line 91
Provides interface and database handling for e-mail settings of a webform.

Code

function theme_webform_emails_form($form) {

  // Add CSS to display submission info. Don't preprocess because this CSS file is used rarely.
  drupal_add_css(drupal_get_path('module', 'webform') . '/css/webform-admin.css', 'theme', 'all', FALSE);
  drupal_add_js(drupal_get_path('module', 'webform') . '/js/webform-admin.js', 'module', 'header', FALSE, TRUE, FALSE);
  $node = $form['#node'];
  $header = array(
    t('E-mail to'),
    t('Subject'),
    t('From'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $rows = array();
  if (!empty($form['emails'])) {
    foreach (element_children($form['emails']) as $eid) {

      // Add each component to a table row.
      $rows[] = array(
        drupal_render($form['emails'][$eid]['email']),
        drupal_render($form['emails'][$eid]['subject']),
        drupal_render($form['emails'][$eid]['from']),
        l(t('Edit'), 'node/' . $node->nid . '/webform/emails/' . $eid),
        l(t('Delete'), 'node/' . $node->nid . '/webform/emails/' . $eid . '/delete'),
      );
    }
  }
  else {
    $rows[] = array(
      array(
        'data' => t('Currently not sending e-mails, add an e-mail recipient below.'),
        'colspan' => 5,
      ),
    );
  }

  // Add a row containing form elements for a new item.
  $row_data = array(
    array(
      'colspan' => 3,
      'data' => drupal_render($form['add']),
    ),
    array(
      'colspan' => 2,
      'data' => drupal_render($form['add_button']),
    ),
  );
  $rows[] = array(
    'data' => $row_data,
    'class' => 'webform-add-form',
  );
  $output = '';
  $output .= theme('table', $header, $rows, array(
    'id' => 'webform-emails',
  ));
  $output .= drupal_render($form);
  return $output;
}