When using the 'Dependencies' tab on a content type any 'date' fields in that content type become broken. After setting dependencies on a content type (not related to the date field), the content type stops displaying the correct date for the piece of content. The field value stays accurate, but anywhere the field value is supposed to be displayed (either on the content view page, or any pages that display this field specifically), all show the current date, not the field values date. (Regardless of what date todays date is, the same piece of content will change the display based on what the actual date is the day you view it).

Removing dependencies from the content type fixes the issue, and it starts displaying the correct date again.

NOTE: Originally this was working, but I created a feature and included the content type in it. After importing the feature to another site is when it started happening. (I have since removed it from the feature, and even recreating the content-type from scratch causes the issue again).

Comments

jfurnas created an issue. See original summary.

jfurnas’s picture

Status: Active » Closed (outdated)
crutch’s picture

Status: Closed (outdated) » Active

Experiencing the same issue.

I have a content type with a conditional field. The conditional field is Course Type with options of: Type 1, Type 2, Type 3.

The date field is the same no matter the choice and is not a dependent nor dependee. It uses the same View display.

When Type 1 is selected, date is displayed with proper EST offset. When Type 2 or 3 is selected, date/time is double offset. So instead of it being UTC -5 its UTC -10.

In other words I have it set for EST (-5)
...the date field is set to use the site time zone handling, site time zone is set at EST (-5)

After entering the dates and saving, then going back to edit, the times are set to -5 (-4 if no daylight savings time) from what I originally selected. If I enter 10am-2pm, it saves as 5am-9am only when Type 2 and Type 3 are chosen but not Type 1.

So I removed all conditions, then date saves properly no matter the choice.

crutch’s picture

I've found that 2 required dependent fields are causing a problem with date field.

#1 is the 2nd of 3 Float fields in which all floats are required. All are dependents. But the problem only occurs when this second one is required but hidden. (This field is #14 of 29)

AND/OR

#2 is a Long Text required field. When it is hidden and has no value it is also causing the problem with date. (This field is #17 of 29)

When making them both not required, then date saves properly. If I make them both required with default values, then date saves properly.

However, it will confuse the maintainer if default values are in those required fields so to get around this I will need to create rules to fill those hidden required fields with some values when saved.

Seems that there is something in Conditional Fields and required fields with no values that alter how date entries are saved. There seems to be no logic of why the #1 and #2 fields above are part of the problem or why only these two hidden required fields cause the problem when other hidden required fields do not.

UPDATE: Using a rule to set those 2 required field values doesn't fix the date field issue because date is saved before rule field values are altered. Using a rule to alter the date +4 hours if Type 2 or Type 3 is chosen sort of works but the maintainers can add unlimited dates so that is not feasible for us. If it was a single start and end date that would work.

Temp solution: So I had to make those fields #1 and #2 above not required, then create rules to check those fields: if Type 1 is selected, display an error messages for those 2 fields if no values are entered. This can be a little confusing because those fields do not have the asterisk and they aren't highlighted on error. This will be explained to the maintainers to be able to continue using Conditional Fields. With CSS I have added red boxes around these two items to identify them as required.

dqd’s picture

Title: Conditional fields not working with Date module » Support for Date module
Version: 7.x-3.0-alpha2 » 7.x-3.x-dev
Category: Bug report » Feature request
Priority: Critical » Normal
Status: Active » Closed (outdated)

Thanks for the report and all the efforts in here. But due to inactivity in this issue for some years and because of the upcoming EOL of Drupal 7, I will close this issue on the way cleaning up the issue queue.

Feel free to re-open as "Needs review" if you found a solution or have a patch to be reported to help others. If this feature request is still wanted in newer versions of this project for Drupal core 8 and above, please file a new issue as Feature request.