Date module -dev snapshot of July, 8th, Drupal 5.7, PHP 5.1.6

CCK Date field, Select list, Default values: blank, Multiple: Never, No time zone conversion, From date: required, To date: required.

"From" date works as required, while "To" date is treated as optional, whether it's set as required or not. I've assumed it's a PHP4 problem (following this #272523: PHP4? Problem using 'Date repeat' and 'To date' simultaniusly), but I'm not sure, as I can't test on PHP 5.2. Unfortunately I have to stay with PHP 5.1, it's a shared host.

Comments

KarenS’s picture

Basically there is no longer any difference between 'required' and 'optional'. There really was never any difference (optional dates get filled in with the 'from date'), the reason in the past was so there was a way to have the 'to' date blank. But now you can control the default value of the 'to' date and set it to blank yourself.

I've just been thinking about whether I should just get rid of that option and only have an option to allow or not allow a 'To date'.

What would be the reason for needing one over the other (knowing that the database is going to have to look the same either way)? The only one I can think of is to show the 'To date' as blank if it's the same as the 'From date'.

burlap’s picture

I think that required "To date" might be useful, like in my case, where I expect the user to fill in both dates (of an internship - it is not possible for the "To date" to be the same as "From" and durations are quite different too). Users generally tend to omit even important information, unless they can't submit a form which is not filled out completely.

As probably I won't need a calendar for that content type, and this behavior is "by design", as a workaround I'll create two separate date fields, which will be both required. Worse, I know that I'll need a calendar for this project for other content (soon), so I'll have to figure something out anyway.

Thanks for a quick reply and a great module, too.

KarenS’s picture

Title: PHP4?: required "To:" date treated as optional » Required "To:" date treated as optional
Component: PHP4 Module » Code
Category: bug » feature

This is not a PHP4 issue, so lets clean this up a bit. OK, I can see that use case. At the moment it's not designed to work that way, though, so this is a feature request.

KarenS’s picture

Version: 5.x-2.x-dev » 6.x-2.x-dev

I've been thinking about how to implement this without going back to the previous, very cumbersome, requirement that every single part of the second date must be filled out. I think the new behavior of only filling out parts that change in the second date is much nicer.

But as I think about this more, it's not really about requiring a 'To' date, it's about requiring that the 'To' date not equal the 'From' date, right? That's actually a little different and might be another validation setting for the module.

Or maybe we say that required 'To' dates must be filled out, and limit the 'allow empty values' behavior to optional 'To dates'. That would allow people to use that when it makes sense.

Anyway, bumping this to 6.x because that's where feature requests go, but we can then backport it to 5.2.

KarenS’s picture

Status: Active » Closed (duplicate)

There's a later issue for the D5 version that has a patch. This part of the code is the same in both versions, so the same fix could apply. Would that fix work for your situation? Either way, let's mark this a duplicate and move to the issue that has an actual patch.