Steven,<br><br>Check out p. 177 of the Drupal 5 version of "Pro Drupal Development". There's a little code snippit that might be of interest:<br><br>A select element example from statistics.module follows:<br>
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800,<br>259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');<br>/* Period now looks like this:<br>Array (<br>[3600] => 1 hour<br>
[10800] => 3 hours<br>[21600] => 6 hours<br>[32400] => 9 hours<br>[43200] => 12 hours<br>[86400] => 1 day<br>[172800] => 2 days<br>[259200] => 3 days<br>[604800] => 1 week<br>[1209600] => 2 weeks<br>
[2419200] => 4 weeks<br>[4838400] => 8 weeks<br>[9676800] => 16 weeks )<br>*/<br>$form['access']['statistics_flush_accesslog_timer'] = array(<br>'#type' => 'select',<br>'#title' => t('Discard access logs older than'),<br>
'#default_value' => variable_get('statistics_flush_accesslog_timer', 259200),<br>'#options' => $period,<br>'#description' => t('Older access log entries (including referrer statistics)<br>
will be automatically discarded. Requires crontab.')<br>);<br><br><div class="gmail_quote">On 12 May 2011 20:00, <span dir="ltr"><<a href="mailto:development-request@drupal.org">development-request@drupal.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Send development mailing list submissions to<br>
<a href="mailto:development@drupal.org">development@drupal.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.drupal.org/mailman/listinfo/development" target="_blank">http://lists.drupal.org/mailman/listinfo/development</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:development-request@drupal.org">development-request@drupal.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:development-owner@drupal.org">development-owner@drupal.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of development digest..."<br>
<br>Today's Topics:<br>
<br>
1. Time interval inputs (Steven Jones)<br>
2. Re: Time interval inputs (Hai-Nam aka jcisio)<br>
<br><br>---------- Forwarded message ----------<br>From: Steven Jones <<a href="mailto:steven.jones@computerminds.co.uk">steven.jones@computerminds.co.uk</a>><br>To: development <<a href="mailto:development@drupal.org">development@drupal.org</a>><br>
Date: Thu, 12 May 2011 07:32:02 +0100<br>Subject: [development] Time interval inputs<br>Hello developers,<br>
<br>
I maintain a number of modules that are related to doing something at<br>
a user defined interval, e.g. every 30 minutes or 12 hours etc. Most<br>
times I just use a single select box and pre-generate some options<br>
that I think users will want, but of course some users (myself<br>
included) want to be able choose an exact, but custom, interval.<br>
<br>
Is there any module out there that provides a generic 'interval' form element?<br>
<br>
I've looked at core, and it just uses some custom code each time to<br>
generate a list of intervals and pop them in a select list. I've also<br>
looked at other contrib modules and some of them just provide a<br>
textfield and others provide a textfield for numeric input and a<br>
select list for 'units'. There doesn't seem to be a catch-all solution<br>
that I can find, and everyone seems to implementing intervals in a<br>
slightly different way.<br>
<br>
Regards<br>
Steven Jones<br>
ComputerMinds ltd - Perfect Drupal Websites<br>
<br>
Phone : 024 7666 7277<br>
Mobile : 07702 131 576<br>
Twitter : darthsteven<br>
<a href="http://www.computerminds.co.uk" target="_blank">http://www.computerminds.co.uk</a><br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Hai-Nam aka jcisio <<a href="mailto:jcisio@gmail.com">jcisio@gmail.com</a>><br>To: <a href="mailto:development@drupal.org">development@drupal.org</a><br>Date: Thu, 12 May 2011 09:45:54 +0200<br>
Subject: Re: [development] Time interval inputs<br>Le 12/05/2011 08:32, Steven Jones a écrit :<br>
><br>
> I've looked at core, and it just uses some custom code each time to<br>
> generate a list of intervals and pop them in a select list. I've also<br>
> looked at other contrib modules and some of them just provide a<br>
> textfield and others provide a textfield for numeric input and a<br>
> select list for 'units'. There doesn't seem to be a catch-all solution<br>
> that I can find, and everyone seems to implementing intervals in a<br>
> slightly different way.<br>
><br>
<br>
In one of my module, I use a select list with prefined values to quickly<br>
fill a textfield with a choice. Then user can modify this textfield if<br>
they don't like any of these predefined values.<br>
<br>
Take a look at<br>
<a href="http://drupal.org/project/hidden_comment" target="_blank">http://drupal.org/project/hidden_comment</a><br>
<br>
--<br>
Hai-Nam Nguyen aka jcisio<br>
<a href="http://jcisio.com" target="_blank">http://jcisio.com</a><br>
<br>
<br>--<br>
[ Drupal development list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br></blockquote></div><br>