You are here

itoggle_example.module in iToggle 7.3

iToggle Example module.

File

contrib/itoggle_example/itoggle_example.module
View source
<?php

/**
 * @file
 * iToggle Example module.
 */

/**
 * Implements hook_menu().
 */
function itoggle_example_menu() {
  $items = array();
  $items['examples/itoggle'] = array(
    'title' => 'iToggle example',
    'description' => 'Example of the iToggle Form API element.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'itoggle_example_form',
    ),
    'access callback' => TRUE,
  );
  return $items;
}

/**
 * Form callback.
 *
 * Returns a form using the iToggle Form API element.
 *
 * @see itoggle_example_menu().
 */
function itoggle_example_form($form, $form_state) {
  $form['checkbox'] = array(
    '#type' => 'checkbox',
    '#title' => t('Checkbox'),
  );
  $form['checkboxes'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Checkboxes'),
    '#options' => drupal_map_assoc(array(
      'foo',
      'bar',
      'baz',
    )),
  );
  $form['radios'] = array(
    '#type' => 'radios',
    '#title' => t('Radios'),
    '#options' => drupal_map_assoc(array(
      'foo',
      'bar',
      'baz',
    )),
  );
  $form['itoggle'] = array(
    '#title' => t('iToggle'),
    '#type' => 'itoggle',
    '#itoggle_type' => 'onoff',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}

/**
 * Submit callback.
 *
 * @see itoggle_example_form()
 */
function itoggle_example_form_submit(&$form, &$form_state) {
  $values =& $form_state['values'];
  include_once drupal_get_path('module', 'devel') . '/krumo/class.krumo.php';
  krumo($values);
  die;
}

Functions

Namesort descending Description
itoggle_example_form Form callback.
itoggle_example_form_submit Submit callback.
itoggle_example_menu Implements hook_menu().