Fix for Attempt at a custom element to represent a 24 hour clock.

  1. <?php                                                                          
  2. // $Id
  3.  
  4. function timeform_element_menu() {
  5.   $items['timeform/element'] = array(
  6.     'title' => 'Test timeform element',
  7.     'page callback' => 'drupal_get_form',
  8.     'page arguments' => array('timeform_element_form'),
  9.     'access arguments' => array('access content'),
  10.   );
  11.   return $items;
  12. }
  13.  
  14. function timeform_element_elements() {
  15.   $type['timeform'] = array(
  16.     '#input' => TRUE,
  17.     '#process' => array('timeform_element_time_expand'),
  18.     '#element_validate' => array('timeform_element_time_validate'),
  19.   );
  20.   return $type;
  21. }
  22.  
  23. function timeform_element_time_expand($element) {
  24.   $element['#tree'] = TRUE;                                                    
  25.  
  26.   if (!isset($element['#value'])) {
  27.     $element['#value'] = array(
  28.       'hour' => 0,
  29.       'minute' => 0);
  30.   }
  31.  
  32.   $element['hour'] = array(
  33.     '#type' => 'select',
  34.     '#default_value' => variable_get('feed_item_length', 00),
  35.     '#options' => array(00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23),
  36.     '#required' => TRUE,
  37.   );
  38.   $element['minute'] = array(
  39.     '#type' => 'select',
  40.     '#default_value' => variable_get('feed_item_length', 00),
  41.     '#options' => array(00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59),
  42.     '#required' => TRUE,
  43.     '#prefix' => t(':'),
  44.   );
  45.  
  46.   return $element;
  47. }
  48.  
  49. function timeform_element_time_validate($form, &$form_state) {
  50.   return $form;
  51. }
  52.  
  53. function timeform_element_theme() {
  54.   return array(
  55.     'timeform' => array(
  56.       'arguments' => array('element'),
  57.     ),
  58.   );
  59. }
  60.  
  61. function theme_timeform($element) {
  62.   return theme('form_element', $element, '<div class="container-inline">' . $element['#children'] . '</div>');
  63. }
  64.  
  65. function timeform_element_form() {
  66.   return system_settings_form($form);
  67. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.