You are here

function registration_registrations_broadcast_form in Entity Registration 8.2

Same name and namespace in other branches
  1. 8 includes/registration.forms.inc \registration_registrations_broadcast_form()
  2. 7.2 includes/registration.forms.inc \registration_registrations_broadcast_form()
  3. 7 includes/registration.forms.inc \registration_registrations_broadcast_form()

Return a form for sending a broadcast email to participants.

1 string reference to 'registration_registrations_broadcast_form'
registration_menu in ./registration.module
@FIXME This implementation of hook_menu() cannot be automatically converted because it contains logic (i.e., branching statements, function calls, object instantiation, etc.) You will need to convert it manually. Sorry!

File

includes/registration.forms.inc, line 424
Form definitions and callbacks for Registration.

Code

function registration_registrations_broadcast_form($form, &$form_state, $entity_type, $entity) {

  // We'll need this info when we submit the form.
  list($entity_id) = entity_extract_ids($entity_type, $entity);
  $form_state['entity'] = array(
    'entity_id' => $entity_id,
    'entity_type' => $entity_type,
  );
  $form['subject'] = array(
    '#type' => 'textfield',
    '#title' => t('Subject'),
    '#description' => t('The subject of the message.'),
    '#required' => TRUE,
    '#size' => 40,
    '#maxlength' => 40,
  );
  $form['message'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#description' => t('Enter the message you want to send to %name registrants. Tokens are supported if the module is enabled, E.g., [node:title].', array(
      '%name' => $entity
        ->label(),
    )),
    '#required' => TRUE,
    '#cols' => 60,
    '#rows' => 5,
  );

  // Message preview:
  if (isset($form_state['registration_broadcast_preview'])) {
    $form['preview'] = array(
      '#type' => 'textarea',
      '#title' => t('Message preview'),
      '#value' => $form_state['registration_broadcast_preview'],
      '#resizable' => FALSE,
      '#disabled' => TRUE,
    );
  }

  // Add token support:
  if (\Drupal::moduleHandler()
    ->moduleExists('token')) {
    $form['token_tree'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(
        $entity_type,
        'registration',
      ),
      '#global_types' => FALSE,
    );
  }
  $form['actions']['preview'] = array(
    '#type' => 'submit',
    '#value' => t('Preview'),
    '#weight' => 10,
    '#submit' => array(
      'registration_broadcast_preview',
    ),
  );
  $form['actions']['send'] = array(
    '#type' => 'submit',
    '#value' => t('Send'),
  );
  return $form;
}