The current interface to add multiple dates is a bit too hard for our situation, so I was trying to use a list of dates in a textfield to be added to the dates array upon submit. JS calendar actually supports multiple dates and it works very neat. However, even though the array looks exactly the same upon submit, it doesn't get saved.
To illustrate:
// This is the date array upon submit (generated the normal multi-date way)
[field_date_occurrence] => Array
(
[0] => Array
(
[value] => 2007-03-06
)
[timezone] =>
[1] => Array
(
[value] => 2007-03-07
)
[2] => Array
(
[value] => 2007-03-08
)
)
// And this is the array unset and then regenerated via some custom code upon submit
[field_date_occurrence] => Array
(
[0] => Array
(
[value] => 2007-03-06
)
[1] => Array
(
[value] => 2007-03-07
)
[2] => Array
(
[value] => 2007-03-08
)
)
Apart from the timezone they are identical (and I did add the timezone at one stage, just to be sure) , but obviously I'm approaching this from the wrong angle. How can I take advantage of the CCK multidate field, but generate the data via other means? I tried to do the same approach at validation time, but that doesn't work either.
Many thanks...
Comments
Comment #1
karens commentedThe problem is that depending on exactly at what point in the processing you are inserting them, they may have different formats. In some cases you have the format used by the widget, in others the format used by the field. The Date module does some pre and post processing to massage the value used by the widget back into the format needed to be stored in the field. In this case, you may need to insert your dates as complete ISO formatted dates to get them to pass validation.
No guarantees that this will work and I don't have a lot of time to try to figure it out right now. However I have started working on a module to allow you to import dates from other sources, but I don't know when that will be ready.
Comment #2
nicolash commentedYeah, I thought that might be the case. Anyway, I got around it by adding another field to the content type which only purpose is to get the values savely through the validation process until the insert operation in nodeapi, then copy them over to individual date fields. Works like a charm and is really suited for entering any number of dates very quickly.
I wonder whether this could be an additional option when you choose the type of form field? A textarea with a multi-date enabled JS calendar.
Comment #3
karens commentedDoes the Drupal jscalendar module support that? If not, I'd start by posting a feature request there. Nothing I can do here until jscalendar supports it.
Comment #4
jvalletto commentedI'm going to take a wild guess and say yes, it does support it. Seeing how the jscalendar library and the demo's are one in the same. In fact the demo is hosted by the company who wrote the jscalendar library, Drupal uses.
I also did a quick search through the jscalendar library, and I see a multiple option. Haven't tested with it however.
Hope that helps.
Comment #5
karens commentedI'm going to take a wild guess and say it is *not* supported in the Drupal version :-) You need to post on the jscalendar issue queue to find out for sure.
Comment #6
jvalletto commentedWell, after a little investigation, I discovered that while the JSCalendar library used in Drupal does have a multiple option, it is in fact not at all being implemented by the JSCalendar module.
I opened a feature request issue for JSCalendar, seeing if we can get the multiple dates feature working.
We shall see what happens.
Jeremy
Comment #7
nicolash commented@KartenS
No, the Drupal JS calendar doesn't support multiple dates out of the box, but since the original Dynarch Calendar does, it was easy to enable it, so hopefully it will become "official" and I can undo my hack.
@jvalletto
Thanks for opening another issue and yes, that part of this request should be done first. One reason why I haven't put forward what I've done so far is that I haven't figured out yet how to feed the dates back to the JS Calendar when editing a node. The dates need to be in some sort of object which I hadn't had time to look into...
Comment #8
karens commentedThe question about how to feed those multiple dates back into the date module is another issue, but I need to have jscalendar working first because I need to see 1) how the Date code needs to change to enable it, and 2) What those multiple dates look like exactly when the field is submitted. Once I can see that, I don't think it will be hard to update the date module with them.
The only issue I can see right now is deciding how to handle them as multiple dates -- do they replace any multiple dates already stored in the field (the only easy way to interpret the results that I can see)? Also, you won't have any control over order for those dates, it will have to be chronological because there will be no way to put them in any different order.
Changing the title and category to reflect the current discussion.
Comment #9
karens commentedMarking this postponed because it isn't something I can do myself. If someone patches jscalendar and provides a patch for the Date module, I'll look at it as an enhancement for the 5.2 version.
Comment #10
karens commentedMarking this won't fix because I think jsCalendar is going to be superceded by the jQuery calendar. I have a jQuery popup module almost ready to go for the 5.2 version in HEAD. It doesn't yet have date range capability, but a future version is supposed to add that.