You are here

function registration_state_overview_form in Entity Registration 8.2

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

Registration states setting form.

File

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

Code

function registration_state_overview_form($form, &$form_state) {
  $registration_states = registration_states();

  // Form elements for existing states .
  $form['state']['#tree'] = TRUE;
  if (!empty($registration_states)) {
    foreach ($registration_states as $sid => $state) {
      $form['state'][$sid]['sid'] = array(
        '#type' => 'hidden',
        '#default_value' => $sid,
      );
      $form['state'][$sid]['label'] = array(
        '#title' => t('Label'),
        '#type' => 'textfield',
        '#default_value' => $state->label,
        '#maxlength' => 128,
        '#size' => 20,
        '#required' => TRUE,
      );
      $form['state'][$sid]['default_state'] = array(
        '#type' => 'radio',
        '#name' => 'default_state',
        '#return_value' => $sid,
        '#tree' => FALSE,
        '#default_value' => $state->default_state ? $sid : FALSE,
      );
      $form['state'][$sid]['attended'] = array(
        '#type' => 'radio',
        '#name' => 'attended',
        '#return_value' => $sid,
        '#tree' => FALSE,
        '#default_value' => $state->attended ? $sid : FALSE,
      );
      $form['state'][$sid]['weight'] = array(
        '#title' => t('Weight'),
        '#type' => 'weight',
        '#default_value' => $state->weight,
        '#delta' => 15,
        '#attributes' => array(
          'class' => array(
            'registration-state-weight',
          ),
        ),
      );
      $form['state'][$sid]['description'] = array(
        '#title' => t('Description'),
        '#type' => 'textfield',
        '#default_value' => $state->description,
        '#maxlength' => 128,
        '#size' => 50,
      );
      $form['state'][$sid]['active'] = array(
        '#title' => t('Active'),
        '#type' => 'checkbox',
        '#default_value' => $state->active,
      );
      $form['state'][$sid]['held'] = array(
        '#title' => t('Held'),
        '#type' => 'checkbox',
        '#default_value' => $state->held,
      );
      $form['state'][$sid]['show_on_form'] = array(
        '#title' => t('Show on form'),
        '#type' => 'checkbox',
        '#default_value' => $state->show_on_form,
      );

      // @FIXME
      // l() expects a Url object, created from a route name or external URI.
      // $form['state'][$sid]['delete'] = array(
      //         '#type' => 'item',
      //         '#markup' => l(t('delete'), 'admin/structure/registration/registration_states/manage/' . $state->identifier() . '/delete', array('query' => drupal_get_destination())),
      //       );
      // @FIXME
      // l() expects a Url object, created from a route name or external URI.
      // $form['state'][$sid]['export'] = array(
      //         '#type' => 'item',
      //         '#markup' => l(t('export'), 'admin/structure/registration/registration_states/manage/' . $state->identifier() . '/export'),
      //       );
    }
  }
  $form['help'] = array(
    '#type' => 'item',
    '#description' => t("This table defines the registration states available on this site. A default is required and will be used if no states are marked as 'Show on Form'."),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  return $form;
}