You are here

function theme_webform_emails_form in Webform 7.3

Same name and namespace in other branches
  1. 6.3 includes/webform.emails.inc \theme_webform_emails_form()
  2. 7.4 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 94
Provides interface and database handling for e-mail settings of a webform.

Code

function theme_webform_emails_form($variables) {
  $form = $variables['form'];
  $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' => array(
      'webform-add-form',
    ),
  );
  $output = '';
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'webform-emails',
    ),
  ));
  $output .= drupal_render_children($form);
  return $output;
}