By norio on
I've just launched www.jogmymemory.co.za and people are complaining that the calendar time-selector is difficult to use.
How can I create a new time-field for the forms API? I've read some docs on the site but they didn't make much sense.
I'd basically be happy with a date field that has drop downs for year, month, day, hour & minute.
Comments
JSTools
JSTools has a nice calendar widget for you. http://drupal.org/project/jstools
There is also #date for form api: http://api.drupal.org/api/4.7/file/developer/topics/forms_api_reference....
Thanks for your reply, Scott
Thanks for your reply, Scott :)
I'm already using the widget from JSTools -- that's what people are complaining about :/
As for #date, does it allow me to specify the time via hours and minutes dropdowns?
Finally got it right using
Finally got it right using hook_elements but what a mission!
Any chance of the code for the time widget?
How did you do this? I'm interested in this code as I need it for a data export module i'm writing...
Time Widget
It's basically a modified version of the date widget. Anyway, here you go :)
(Oh and I don't use Drupal's built-in date functions which means that the time is always the same timezone as the server it's on.
re: Time Widget
Nice... just tried it and it looks like it's working. :) Thanks!
-Mike Cantelon
http://mikecantelon.com
Minor change to work with Drupal 5.1
If you use the code posted above in Drupal 5.1, you won't able to see title and description. I did minor modification and it works like charm.
Change,
To,
Regards,
Dhaval
Here is yet another version
Here is my rendition of the time form type element. I would have prefered to have it a text field with user inputed values but all the regular expressions and logic to allow for any valid input made my head spin and my regex knowledge isn't what I would like. So here you go... This code was built and tested on drupal 5.2.x
Peace,
-mpare
www.paretech.com
Did you figure out how to do something? Did you find documentation on Drupal.org inadequate? Well now it's your turn. Document your Success!
Problem with setting default time
The above code uses the 'h' format for Hour and 'i' format for Minutes, which return values including leading zeros. However, to act as a proper default value for the HTML SELECT tag, leading zeros do not work. In the SELECT tag you'll notice that the actual *value* of each option doesn't have any leading zero...just the display string has the leading zeros to keep the values properly sorted.
So the above code only properly pre-selects the correct default hour and minute if the hour is 10,11,12 and the minute is >= 10. Here is the modified code I used to fix this. I've included the full code to make it easier for people to use it, but the change is just in the first few lines. Also added the $parents code taken from the existing expand_date code in form.inc and removed the unneeded time_value function.
SMS sent by Drupal?
Norio Hi,
I saw that your site offers SMS notification services.
Is there some ready-to-use functionality in Drupal for generating SMS?
Thanks,
Sam
Thanks Dhaval
I needed this code again, and thanks to Dhaval, I could quickly and easily get it working in Drupal 5. Thanks :)