You are here

function webform_emails_form in Webform 6.3

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

Overview form of all components for this webform.

1 string reference to 'webform_emails_form'
webform_menu in ./webform.module
Implements hook_menu().

File

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

Code

function webform_emails_form($form_state, $node) {
  module_load_include('inc', 'webform', 'includes/webform.components');
  $form['#tree'] = TRUE;
  $form['#node'] = $node;
  $form['components'] = array();
  $form['nid'] = array(
    '#type' => 'value',
    '#value' => $node->nid,
  );
  foreach ($node->webform['emails'] as $eid => $email) {
    $email_addresses = array_filter(explode(',', $email['email']));
    foreach ($email_addresses as $key => $email_address) {
      $email_addresses[$key] = check_plain(webform_format_email_address($email_address, NULL, $node, NULL, FALSE));
    }
    $form['emails'][$eid]['email'] = array(
      '#value' => implode('<br />', $email_addresses),
    );
    $form['emails'][$eid]['subject'] = array(
      '#value' => check_plain(webform_format_email_subject($email['subject'], $node)),
    );
    $form['emails'][$eid]['from'] = array(
      '#value' => check_plain(webform_format_email_address($email['from_address'], $email['from_name'], $node, NULL, FALSE)),
    );
  }
  $form['add'] = array(
    '#theme' => 'webform_email_add_form',
    '#tree' => FALSE,
  );
  $form['add']['email_option'] = array(
    '#type' => 'radios',
    '#options' => array(
      'custom' => t('Address'),
      'component' => t('Component value'),
    ),
    '#default_value' => 'custom',
  );
  $form['add']['email_custom'] = array(
    '#type' => 'textfield',
    '#size' => 24,
    '#maxlength' => 500,
  );
  $form['add']['email_component'] = array(
    '#type' => 'select',
    '#options' => webform_component_list($node, 'email_address', FALSE),
  );
  if (empty($form['add']['email_component']['#options'])) {
    $form['add']['email_component']['#options'][''] = t('No available components');
    $form['add']['email_component']['#disabled'] = TRUE;
  }
  $form['add_button'] = array(
    '#type' => 'submit',
    '#value' => t('Add'),
    '#weight' => 45,
  );
  $form['#validate'] = array(
    'webform_email_address_validate',
  );
  return $form;
}