You are here

function theme_webform_email_edit_form in Webform 7.4

Same name and namespace in other branches
  1. 6.3 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 423
Provides interface and database handling for e-mail settings of a webform.

Code

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

  // Loop through fields, rendering them into radio button options.
  foreach (array(
    'email',
    'subject',
    'from_address',
    'from_name',
  ) as $field) {
    foreach (array(
      'custom',
      'component',
    ) as $option) {
      $form[$field . '_' . $option]['#attributes']['class'][] = 'webform-set-active';
      $form[$field . '_' . $option]['#theme_wrappers'] = array();
      $form[$field . '_option'][$option]['#theme_wrappers'] = array(
        'webform_inline_radio',
      );
      $form[$field . '_option'][$option]['#title'] = t('!title: !field', array(
        '!title' => $form[$field . '_option'][$option]['#title'],
        '!field' => drupal_render($form[$field . '_' . $option]),
      ));
    }
    if (isset($form[$field . '_option']['#options']['default'])) {
      $form[$field]['#theme_wrappers'] = array();
      $form[$field . '_option']['default']['#theme_wrappers'] = array(
        'webform_inline_radio',
      );
    }
  }
  $details = '';
  $details .= drupal_render($form['subject_option']);
  $details .= drupal_render($form['from_address_option']);
  $details .= drupal_render($form['from_address_mapping']);
  $details .= drupal_render($form['from_name_option']);
  $form['details'] = array(
    '#type' => 'fieldset',
    '#title' => t('E-mail header details'),
    '#weight' => 10,
    '#children' => $details,
    '#collapsible' => FALSE,
    '#parents' => array(
      'details',
    ),
    '#groups' => array(
      'details' => array(),
    ),
    '#attributes' => array(),
  );

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

  // Re-sort the elements since we added the details fieldset.
  $form['#sorted'] = FALSE;
  $children = element_children($form, TRUE);
  return drupal_render_children($form, $children);
}