Still looking to use this module to force entry of multiple single dates, but having multiple values and using the "add another item" button breaks the single date field display.

I have a site where I need to be able to have users enter a span of time as individual dates, both for views display purposes, and for the fact that each date may have different start and end times (ie. for rummage sales that may be open 8-5 one day and 9-2 on another).

I know this is tricky because of CCK's use of AJAX for adding multiple values, but this is something I really need to have for this (and other planned future sites). (Unfortunately I don't have the coding knowledge to contribute myself) Thanks!

Comments

joachim’s picture

This is something I have neither the time nor the skills with CCK and FormAPI AHAH to deal with, but let's leave it open and see if another user can contribute a fix :)

thebuckst0p’s picture

Duplicate comment from #830670:

I did that here, would require a slight change to the module to do the same:
Customizing Drupal date field with hook_form_alter and #after_build

iamer’s picture

StatusFileSize
new1.75 KB

@thebuckst0p Taking a hint from your code, I have created a patch that fixes the problem.

Please test :)

@joachim Thanks for your work on this module.

iamer’s picture

Status: Active » Needs review
StatusFileSize
new1.81 KB

I noticed that I didn't check if the field was set as single day or not. Here's a modified patch. Thanks.

joachim’s picture

Status: Needs review » Needs work

Patch works perfectly, but could you explain what this change is for please?

+  $widget_types = array('date_popup', 'date_combo', 'date_popup_repeat');
iamer’s picture

Status: Needs work » Needs review
StatusFileSize
new932 bytes

Sorry, I have another patch to handle date popups with repeat options, and this line crept into this patch. I will submit a separate patch for that. Here's a cleaned up patch.

joachim’s picture

Status: Needs review » Needs work
+++ b/date_single_day.module	2010-08-24 00:01:31.987196563 +0300
@@ -59,7 +59,22 @@
+				  if ( isset($form[$field_name][$key]['#type']) && in_array($form[$field_name][$key]['#type'] , array('date_popup'))){

Seems we need more than just date_popup here -- it's not working with just that.

BTW, if you're rerolling this again, could you make sure to use spaces to indent rather than tabs please?

Powered by Dreditor.

iamer’s picture

StatusFileSize
new1.26 KB

OK, another try at this. I looked back at my changes and I had found that the widget type in the ahah callback is actually 'date_combo' , so that is needed.

'date_popup_repeat' belongs to the other patch.

I changed the indentation to spaces. Vim uses tabs by default.

joachim’s picture

Status: Needs work » Fixed

#815054 by iamer: Fixed operation with 'add another item' button.

Great work -- thanks for figuring all this out! :D

For future reference, check http://drupal.org/coding-standards for matters of indentation (2 spaces not 4) and things like how to do elseif and braces.

Status: Fixed » Closed (fixed)

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