All pastes #834665 Raw Edit

Anonymous

public php v1 · immutable
#834665 ·published 2007-12-28 11:17 UTC
rendered paste body
<?php// $Id$define('CHECKBOX_EXAMPLE_MULTIPAGE', 1); // Change to 0 to make the form a single page./** * Implementation of hook_menu(). */function checkboxes_example_menu($may_cache) {  $items = array();  if ($may_cache) {    $items[] = array(      'path' => 'checkboxes_example',      'title' => t('Checkboxes Example'),      'description' => t(''),      'callback' => 'drupal_get_form',      'callback arguments' => array('checkboxes_example_form'),      'access'   => user_access('view checkboxes'),      'type' => MENU_NORMAL_ITEM,    );  }  return $items;}function checkboxes_example_form($form_values = NULL) {  if (!isset($form_values)) {    $step = 1;  }  else {    $step = $form_values['step'] + 1;  }    $form['step'] = array(    '#type' => 'hidden',    '#value' => $step,  );  switch ($step) {    case 1:      $form['message'] = array(        '#type' => 'item',        '#title' => t('Page'),        '#value' => t('This is the first page of a multistep form.'),      );      if (CHECKBOX_EXAMPLE_MULTIPAGE == 1) {        $form['submit'] = array(          '#type' => 'submit',          '#value' => t('Next'),        );        break;      }          case 2:      $form['message'] = array(        '#type' => 'item',        '#title' => t('Page'),        '#value' => t('This is the second page of a multistep form.'),      );      $form['checks'] = array(        '#type' => 'checkboxes',        '#title' => t('Some options'),        '#description' => t('Items 3 and 5 should be checked'),        '#options' => array(          1 => t('Item 1'),          2 => t('Item 2'),          3 => t('Item 3'),          4 => t('Item 4'),          5 => t('Item 5'),        ),        '#default_value' => array(3, 5),      );      $form['submit'] = array(        '#type' => 'submit',        '#value' => t('Submit'),      );      break;  }    if (CHECKBOX_EXAMPLE_MULTIPAGE == 1) {    $form['#redirect'] = FALSE;    $form['#multistep'] = TRUE;  }  return $form;}function checkboxes_example_form_submit($form_id, $form_values) {}