You are here

function webform_emails_form in Webform 7.4

Same name and namespace in other branches
  1. 6.3 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, $form_state, $node) {
  module_load_include('inc', 'webform', 'includes/webform.components');
  $form['#attached']['library'][] = array(
    'webform',
    'admin',
  );
  $form['#tree'] = TRUE;
  $form['#node'] = $node;
  $form['components'] = array();
  foreach ($node->webform['emails'] as $eid => $email) {
    $form['emails'][$eid]['status'] = array(
      '#type' => 'checkbox',
      '#default_value' => $email['status'],
    );
    $form['emails'][$eid]['email'] = array(
      '#markup' => nl2br(check_plain(implode("\n", webform_format_email_address($email['email'], NULL, $node, NULL, FALSE, FALSE)))),
    );
    $form['emails'][$eid]['subject'] = array(
      '#markup' => check_plain(webform_format_email_subject($email['subject'], $node)),
    );
    $form['emails'][$eid]['from'] = array(
      '#markup' => 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']['status'] = array(
    '#type' => 'checkbox',
    '#default_value' => TRUE,
  );
  $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']['add'] = array(
    '#type' => 'submit',
    '#value' => t('Add'),
    '#validate' => array(
      'webform_email_address_validate',
    ),
    '#submit' => array(
      'webform_emails_form_submit',
    ),
  );
  $form['actions'] = array(
    '#type' => 'actions',
    '#weight' => 45,
  );
  $form['actions']['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#submit' => array(
      'webform_emails_form_status_save',
    ),
    '#access' => count($node->webform['emails']) > 0,
  );
  return $form;
}