You are here

function commons_events_attend_event_form in Drupal Commons 7.3

Form builder for Attend call to action on events, as long as registration is available onsite.

3 string references to 'commons_events_attend_event_form'
commons_events_forms in modules/commons/commons_events/commons_events.module
Implements hook_forms().
commons_origins_preprocess_form_content in themes/commons/commons_origins/template.php
Implements hook_preprocess_form_content().
theme_commons_events_attending_event in modules/commons/commons_events/includes/commons_events.theme.inc
Theme callback to display that a user is attending an event.

File

modules/commons/commons_events/includes/commons_events.forms.inc, line 11
Commons Events form declarations.

Code

function commons_events_attend_event_form($form, &$form_state, $event_node, $registration = NULL, $attendee_count = 0) {
  $form_state['event_node'] = $event_node;
  if (!registration_status('node', $event_node->nid, TRUE)) {
    return array();
  }
  if (!isset($registration)) {
    $registration_type = registration_get_entity_registration_type('node', $event_node);
    $registration = entity_get_controller('registration')
      ->create(array(
      'entity_type' => 'node',
      'entity_id' => $event_node->nid,
      'type' => $registration_type,
    ));
  }
  $form_state['registration'] = $registration;
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Attend'),
  );
  $form['count'] = array(
    '#type' => 'textfield',
    '#default_value' => '0',
    '#description' => t('+ Guests'),
    '#size' => 2,
    '#maxlength' => 2,
    '#required' => false,
  );
  $form['attending'] = array(
    '#theme_wrappers' => array(
      'container',
    ),
    '#attributes' => array(
      'class' => array(
        'commons-event-status',
      ),
    ),
    '#markup' => format_plural($attendee_count, '<span class="commons-event-count">1</span> attendee', '<span class="commons-event-count">@count</span> attendees'),
  );
  $form['#attached']['css'] = array(
    drupal_get_path('module', 'commons_events') . '/css/commons_events.css',
  );
  $form['#attributes'] = array(
    'class' => array(
      'commons-events-form-float',
    ),
  );
  return $form;
}