Calendar Date selector component
febbraro - June 28, 2006 - 01:57
| Project: | Webform |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Hey everyone,
I needed a calendar/date component that was better than those dropdowns. I used the JSTools/JSCalendar module and I wrote a component that can be added to the webforms. I had trouble getting it to specify the format and afew other config parameters. Maybe I can work with you to figure out how to add it. Anyway. I attached the file, feel free to include it in CVS/releases if you like.
| Attachment | Size |
|---|---|
| calendar.inc | 2.87 KB |

#1
This looks like it's for the webform module rather than javascript tools.
#2
This looks pretty cool. I didn't know there was a JSCalendar module. Both the time and date components need a TLC to help them become more compatible with 3rd-party modules. The list of requested features for webform is getting a little lengthy, so I don't think I'll have time to put this together.
#3
We have no plans to include the JS calendar into this release of webform. I'm planning on starting a 'new' webform which uses CCK fields instead of small customized solutions. The date.module already supports this functionality.
#4
I used this component with my Drupal 4.7 version of Webform and it was completely fulfilling my needs. Now, as I intend to migrate to Drupal 5.0, is there a Drupal 5 compatible version of it available? It would also be great to have it as part of the supported components of the module.
#5
http://atlantis.ki.iif.hu/drupal/webform+jscalendar.drupal5.1.tgz
Here is the Drupal 5.1 version. :-)
calendar.inc (date+time)
calendar_date.inc (date)
Gabor
#6
Thanks a lot Gabor..
this is exactly what i was looking for but unfortunately it gives me an error with Drupal 5.3:
* warning: mysql_real_escape_string() expects parameter 1 to be string, array given in D:\xampp\htdocs\aude\includes\database.mysql.inc on line 400.
* warning: mysql_real_escape_string() expects parameter 1 to be string, array given in D:\xampp\htdocs\aude\includes\database.mysql.inc on line 400.
any thoughts on this?
best regards
Johannes
#7
bump. i'd really be interested in this too. just updated to 5.5. havent had a chance to do the include yet but i want the jscalendar functionality if at all possible.
#8
There are no plans for a 6.x version of the JSCalendar module, as the original jscalendar library is no longer maintained. I believe a jQuery-based date picker was integrated into the Date package.
#9
Is it possible to use jQuery 'Date popup' with Webform yet?
I'll try to succeed with this and if you'd like to help me, please don't hesitate to drop me a line...
#10
No, this still isn't possible with Webform. We'd need to convert webform's date.inc to use #type = 'date' instead of 3 separate fields. This would also probably involve a database update to make date fields store as timestamps instead of individual values.
#11
Marked http://drupal.org/node/252609 as duplicate.
#12
Why not integrate it with the Date popup module? It's based on jquery and there's another modules using it.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/date/date_p...
#13
An update on where Webform stands in regard to this request:
- Webform was refactored since my comment in #3, but CCK fields still aren't ready to be used by 3rd party modules, so no progress on that front.
- I've looked at the Date popup module before, but unfortunately it only works with plain-text fields (like the submitted date when editing nodes). This means that it operates differently than Webform's existing date.inc and cannot be used easily.
- I also looked into JS tool's popup calendar, but it operates in a way similar to the Date popup module and has been discontinued in Drupal 6.
So ultimately I'd still like to have a date popup, but no solution currently is available for Webform to use (easily).
#14
Here's a patch to make webform's date element use date_popup. It essentially converts the separate month and date fields into a single text field on the way in, and parses them back out before returning control to the regular date field processing code. There are no changes to the way the data is stored in the the database.
The only down side to this is that it doesn't degrade gracefully. If the user's browser doesn't do Javascript, they will get a textfield instead of the nice selects that the date component normally uses. So perhaps this should be an option in the date component?
#15
Nice! Thanks Gribnif. Yeah, I've also noticed that date_popup doesn't degrade whatsoever, hence why I've avoided using it. The optimal solution would be a date popup that modifies the normal "date" component in Drupal (the one with 3 select lists for month/day/year).
I noticed YUI has support for this: http://developer.yahoo.com/yui/examples/calendar/formsel.html, and there's even a Drupal module that implements it: http://drupal.org/project/yui_calendar. Unfortunately it requires the YUI JS library, adding a bit of overhead and there isn't a jQuery alternative.
If this gets included, we'll definitely need to make in an option, rather than forcing it upon all elements. What does everyone else think?
#16
IMHO, it would be silly to add the overhead of a second JS library (YUI) for this feature. Also, unless it's just not this way in the demo, the YUI calendar isn't a popup. It always takes up a lot of real estate, because it's always visible.
It would be far better to rewrite the JQuery one to gracefully degrade the selects, rather than a text field. It might even be possible to do this by adding some JS, without modifying the JQuery calendar code at all.
#17
I totally agree. I was just pointing out that YUI behaves mostly the way I'd like it to, unlike the the jQuery calendar.
I'd be really interested in this. I'd love if the "supported" jQuery calendar had this ability. If necessary, I also wouldn't mind making a "calendar.js" file to go along with the date component.
I also recalled another option, the excellent jCalendar plugin written by Ted Serbinski (m3averick) at http://tedserbinski.com/jcalendar/index.html, which works beautifully. Unfortunately he's stopped development on it because it's been deprecated in preference of http://plugins.jquery.com/project/jquery-calendar
#18
Oh, looks like jquery-calendar *does* support drop-down selects, with "a little bit of wiring" according to the demo site: http://ui.jquery.com/repository/latest/demos/functional/#ui-gen-9
#19
subscribing. do we have updates on this issue?
#20
Subscribing...
#21
Subscribing
#22
Subscribing
#23
Subscribing
#24
Subscribing
#25
Subscribing
#26
subscribing
#27
subscribing
#28
yet another subscriber
#29
Subscribing...
#30
subscribing
#31
subscribing
#32
jQuery Calendar is now called jQuery UI Datepicker, and part of the official jQuery UI. I'm not certain whether multiple altField and altFormat options could be specified to tie the picker to multiple fields.
Keith Wood's fork/implementation, though, distinctly includes facilities for connecting the picker to multiple form elements: on http://keith-wood.name/datepick.html, click the Miscellaneous tab, and see the Linked to drop-downs example.
#33
A suggestion to get this moving again...
It seems to me we're looking at 3 options for date selection, (which I'll name to show my bias:)
Since 95% of web users have Javascript enabled, I suggest we provide the Best functionality to that 95%, and degrade to Fine for the other 5% -- instead of just providing Decent for everybody.
So, we offload the picker functionality to Date Popup -- via Gribnif's patch -- then focus/consolidate efforts on helping Date Popup to degrade to Decent.
#34
subscribing
#35
subscribing
#36
I'm also in need of a date popup solution for some fields in my webform...
#37
Here is Gribnif's patch from #14, rerolled for the current Webform 6.x-2.x-dev.
It seems to work appropriately: provided the Date Popup calendar to me in a webform date field, and the dates I chose were correctly reflected by the form submission results.
This patch works for the 6.x-2.7 Webform release, as well.
#38
Patch worked great 6.x-2.7
Just make sure you install the Date module first (that is where Date Popup calendar comes from) http://drupal.org/project/date
#39
How do I get this patch(thread #37) integrated into the webform module?
Cheers,
#40
@outbackbrazil: the best way to help possibly get this change into Webform is to apply the patch in #37 to Webform 6.x-2.x-dev, (or 6.x-2.7,) test it out as thoroughly as you're able, and report back here on what you found.
"Patch (to be ported)" status is generally reserved for a patch that's been committed to a development version but needs to be backported to an earlier release.
Setting status and version back.
#41
I get a straight up WSOD after applying the patch in #37. I also made sure I had the Date and Date-Pop Up module enabled before hand.
#42
@animelion: what version of Drupal, Webform, and Date?
Are you using JQuery UI?
Can you look at your webserver (& Drupal) error logs to see what the error was? -- Check out the WSOD diagnosis page.
#43
Sorry my setup has changed so much since then that I would not be able to re-duplicate that scenario.
#44
Applied patch from #37 to Webform 6.x-2.9 and all is working well so far. A very useful addition, thanks.
#45
One feature request (or perhaps 2). As quicksketch mentioned in #15, would it be possible to make this an option on a per-field basis? For e.g. I'd like a "Date of Birth" field to have the usual dropdowns.
Also, is it possible to change the default year range of 3 years either side of the current year? The year fields already exist in the configuration for the date field but the popup seems to ignore them.
#46
Here's a quick and dirty to allow date_popup to use the date range specified in the webform date field configuration. The following lines go in date.inc after it has been patched (#37), line 125 right after
$form_item['#date_format'] = $date_format;:<?php// Get year range
$current_year = date('Y', strtotime('now'));
$form_item['#date_year_range'] = ($component['extra']['year_start'] - $current_year) . ':+' . ($component['extra']['year_end'] - $current_year);
?>
#47
Hi all,
Pretty new to all this, so apologies beforehand...
Tried to apply the patch with Webform 6.x-2.9 and got the following error:
Fatal error: require_once() [function.require]: Failed opening required './sites/all/modules/webform/components/date.inc' (include_path='.;C:\www\php\pear\') in C:\www\htdocs\drupal\src\drupal\includes\module.inc on line 262
Any help would be greatly appreciated...
M
#48
#37 works nice