I have a date field, among others, inside a content multigroup. I enter one group and fill in the date, then create a second, empty group, then delete that empty group and save the node. On the view page, the date for group 1 is empty, and that date has jumped down to the second group (even though that second group was deleted).

I've attached a screenshot that shows what I'm talking about. It seems to only be happening with the date field.

Comments

markus_petrux’s picture

Status:Active» Postponed (maintainer needs more info)

I cannot reproduce this problem. It works here as expected. Tested several multigroups where a date field is combined with other fields as well.

I'm using latest development version of CCK3 + latest development version of Date module. Maybe the difference is there. Otherwise, it's hard to guess when it is not possible to reproduce the problem.

seehawk’s picture

I did some additional testing on this. I made sure I was on the latest dev versions of both Date and CCK. Still had the same problem.

I tested this on two separate installations of Drupal. One is a development site for a project I'm working on. The other is a stripped-down installation that only has the modules installed that I need to create the example.

Hopefully my terminology is correct. When I say that I created a new group, I mean that I clicked the "Add more values" button to get a new collection of fields. I have my groups arranged in a table format, if that makes a difference.

Anyway, I hope this helps. If I can think of any additional info that might be relevant to the bug, I'll post it here.

Thanks!

seehawk’s picture

Status:Postponed (maintainer needs more info)» Active

forgot to reset the status with the new info...

markus_petrux’s picture

Status:Active» Postponed (maintainer needs more info)

I see what you mean, but I'm unable to reproduce the problem here. As far as I can tell it works, so there may be something else...

seehawk’s picture

Status:Postponed (maintainer needs more info)» Active

Eureka!

The problem only happens when the multigroup is viewed as a multiple column table!

To see what I'm talking about, edit the content type, click on Display Fields, and set [Subgroup Format] to "Table - Multiple Columns". Other formats appear to be okay.

markus_petrux’s picture

Status:Active» Postponed (maintainer needs more info)

I also tested this with multiple columns table in the form, and it worked here.

We need more information on how to reproduce this.

seehawk’s picture

Status:Postponed (maintainer needs more info)» Active

Hi Markus,

Just to get a clean test, I created another brand-new install. Here's what I did, step-by-step:

1) Set up a fresh install of Drupal 6.13 on localhost on a Windows NT machine using Wampserver

2) Created \sites\all\modules folder, added CCK 6.x-3.x-dev, dated July 22, 2009

3) Enabled Content, Content Multigroup, Fieldgroup, Text modules

4) Downloaded Date 6.x-2.2 and enabled Date, Date API, Date Popup and Date Timezone

5) Created a new content type called Test Type, and a multigroup within that type called Test Group, using default settings.

6) Added a text field and a date field (with the date popup widget) to the multigroup (using default settings in both cases)

7) Created a content item with two entries in the multigroup

** At this point, everything is working as expected. But...

8) Edited the content item, and clicked Add More Values at the bottom of the multigroup. Then I saved the node, leaving that third item in the group blank.

9) Upon viewing the node, the date has jumped down to a third item in the multigroup. The second item has no date. If I edit the node again, the date has disappeared from the second item, and a third item does not appear.

That's everything. I have no other modules installed on this test installation, and I'm not sure what else I can do from a testing perspective to isolate the problem. If you can think of something, I'll try it. In this case, I wasn't using a table display, so you can probably disregard my last comment about the table being the issue. In this case, I just used defaults.

Thanks!

markus_petrux’s picture

Status:Active» Postponed (maintainer needs more info)

Now that I think of it, we're using fields of type "Datestamp". Not of type "Date". Maybe that makes a difference?

seehawk’s picture

Probably. I'm using date fields with the Date module.

seehawk’s picture

Status:Postponed (maintainer needs more info)» Active

Marking this active again, since the issue persists with Date. If I have an opportunity to test with Datestamp, I will.

markus_petrux’s picture

FYI: We were able to replicate this issue here at the office, so I can now try to debug, etc... :)

seehawk’s picture

Yay! I'm not insane!

(well, ok...maybe a little.) :-)

markus_petrux’s picture

Well, I think I've been able to track down the problem. When a date field is left empty, it is the #element_validate handlers in date that alters the values of the fields in the form state to NULL, and when it does, the weight of the item in the multigroup is lost. This causes the code in CCK/Multigroups that sorts fields by weight to move those with no weight upper than those that have a weight greater than 0.

Now I need to find a way to keep track of the weight regardless of the things that #element_validate handlers do on their widget elements.

Work in progress...

markus_petrux’s picture

Status:Active» Needs review
StatusFileSize
new4.38 KB

Ok, here's a patch that should fix this.

I'm added an element validate callback to all fields in a multigroup. This callback is appended at the end of the list of other element validate callbacks. This way we can ensure the '_weight' and '_remove' attributes of the element have not been removed by element validate callback of the widgets.

It should solve the problem with dates as well as any other widget that behaves in the same way with element validation callbacks.

edemus’s picture

Thanks markus, works perfectly
the other thread bout date issue might be closed i believe #401326: Support empty values and multigroup

markus_petrux’s picture

Oh, now I realize that I missed this problem for more than I thought. Well, I just marked that issue in Date module queue as fixed. We needed to find a way to solve this within the context of multigroup.

If someone else can confirm this works, I think we can commit this to CVS. :)

@edemus: Thanks for the feedback.

markus_petrux’s picture

Title:Date field jumps when fieldset is deleted.» Date field jumps delta when date field is emptied or fieldset is deleted
Status:Needs review» Fixed

Committed the patch in #14 to CVS.

@seehawk: Thanks for your perseverance.

@edemus: Thanks for testing. Much appreciated.

seehawk’s picture

Thank you, markus! Multigroup solves a big issue for me, and I appreciate all your hard work on this!

Status:Fixed» Closed (fixed)

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

sdsheridan’s picture

Status:Closed (fixed)» Active

Ironically, I'm experiencing this issue now, but the only difference is I have two date fields in the multigroup, one completely filled in for each delta, and the other with only the first filled in. However, once the node is saved, the delta in the database reads 2. Sorry to re-open, but not sure what's going on. I have the above patch in the version of CCK I'm using.

What else can I tell you?

Thanks for any help, Shawn

sdsheridan’s picture

Got to love NetBeans. After a few hours of code walk-though, I found the problem. It's actually something in the date module, but surfaces in multigroups. I created a new issue at http://drupal.org/node/1837402 for this.

Shawn