You are here

function token_actions_send_email_action_form in Token 6

Form builder; Prepare a form for a tokenized e-mail action.

See also

token_actions_send_email_action()

token_actions_send_email_action_validate()

token_actions_send_email_action_submit()

File

./token_actions.module, line 90
The Token Actions module.

Code

function token_actions_send_email_action_form($context) {

  // Set default values for form.
  $context += array(
    'recipient' => '',
    'subject' => '',
    'message' => '',
  );
  $form['recipient'] = array(
    '#type' => 'textfield',
    '#title' => t('Recipient'),
    '#default_value' => $context['recipient'],
    '#required' => TRUE,
    '#size' => '20',
    '#maxlength' => '254',
    '#description' => t('The email address to which the message should be sent.'),
    '#element_validate' => array(
      'token_element_validate',
    ),
    '#token_types' => array(
      'all',
    ),
  );
  $form['subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#default_value' => $context['subject'],
    '#size' => '20',
    '#maxlength' => '254',
    '#description' => t('The subject of the message.'),
    '#element_validate' => array(
      'token_element_validate',
    ),
    '#token_types' => array(
      'all',
    ),
  );
  $form['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#default_value' => $context['message'],
    '#required' => TRUE,
    '#cols' => '80',
    '#rows' => '20',
    '#description' => t('The message that should be sent.'),
    '#element_validate' => array(
      'token_element_validate',
    ),
    '#token_types' => array(
      'all',
    ),
  );
  $form['help'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Placeholder tokens'),
    '#description' => t("The following placeholder tokens can be used in to generate the URL path. Some tokens may not be available, depending on the context in which the action is triggered."),
  );
  $form['help']['tokens'] = array(
    '#value' => theme('token_tree', 'all'),
  );
  return $form;
}