You are here

function theme_webform_email_edit_form in Webform 6.3

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

Theme the Webform mail settings section of the node form.

File

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

Code

function theme_webform_email_edit_form($form) {
  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);
  drupal_add_js(array(
    'webform' => array(
      'revertConfirm' => t('Are you sure you want to revert any changes to your template back to the default?'),
    ),
  ), 'setting');

  // Loop through fields, rendering them into radio button options.
  foreach (array(
    'email',
    'subject',
    'from_address',
    'from_name',
  ) as $field) {
    foreach (array(
      'custom' => t('Custom'),
      'component' => t('Component'),
    ) as $option => $title) {
      $form[$field . '_' . $option]['#attributes']['class'] = 'webform-set-active';
      $form[$field . '_option'][$option]['#title'] = $title . ': ' . drupal_render($form[$field . '_' . $option]);
    }

    // For spacing consistency, every option is wrapped in webform-container-inline.
    foreach (element_children($form[$field . '_option']) as $option) {
      $form[$field . '_option'][$option]['#prefix'] = '<div class="webform-container-inline">';
      $form[$field . '_option'][$option]['#suffix'] = '</div>';
    }

    // Wrap the default option in a placeholder tag..
    if (isset($form[$field . '_option']['#options']['default'])) {
      $form[$field . '_option']['default']['#title'] = t('Default') . ': ' . theme('placeholder', $form[$field . '_option']['default']['#title']);
    }
  }
  $details = '';
  $details .= drupal_render($form['subject_option']);
  $details .= drupal_render($form['from_address_option']);
  $details .= drupal_render($form['from_name_option']);
  $form['details'] = array(
    '#type' => 'fieldset',
    '#title' => t('E-mail header details'),
    '#weight' => 10,
    '#children' => $details,
    '#collapsible' => FALSE,
  );

  // Ensure templates are completely hidden.
  $form['templates']['#prefix'] = '<div id="webform-email-templates" style="display: none">';
  $form['templates']['#suffix'] = '</div>';
  return drupal_render($form);
}