Is there a way to change the granularity for the minute selection?

For instance, it would be nice to narrow the list down to 15 minute increments -- :00, :15, :30, :45.

Comments

Digivonity’s picture

This is what I've done to solve the issue:

  1. Opened modules\event\event.module (version 1.215.2.12)
  2. Edited line 1477
    • Before:
      for ($i = 0; $i <= 59; $i++) $minutes[$i] = $i < 10 ? "0$i" : $i;
    • After:
      for ($i = 0; $i <= 59; $i += 15) $minutes[$i] = $i < 10 ? "0$i" : $i;

Of course this patch will last until your next update of the Event module. So it probably would be better if granularity can be changed trough the Event admin page.

killes@www.drop.org’s picture

Status: Active » Fixed

You can use hook_form_alter in your site specific module to change this.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

xurizaemon’s picture

Here's a simple example of what killes is suggesting - using hook_form_alter in your custom module to alter the form before presentation ... improvements welcome!

This approach avoids the tedious effort of having to patch the module on each update, or (worse) having to avoid updating modules because you don't have time to patch them today. It's much, much safer.

I would appreciate any critique on the code below.

function mymodule_form_alter($form_id, &$form) {
  switch( $form_id ) {
  case "event_node_form" :
    $elements = array( 'start', 'end' )  ;
    foreach( $elements as $element) {
      $el_date = 'event_'.$element ;
      $el_mins = $element.'_minute';
      if ( isset($form[$el_date]) && 
	   isset($form[$el_date]['date']) &&
	   isset($form[$el_date]['date'][$el_mins]) ) {
	     $form[$el_date]['date'][$el_mins]['#options'] = array( '00', '15', '30', '45' ) ;
      }
    }
  }
}