Hi,

I have a date field in a field collection (http://www.drupal.org/project/field_collection), which is again nested in another field collection. Now, when you save a node and you set some date values, they're simply not being saved.
This is kind of a crosspost of http://drupal.org/node/1205764, but i can't say which module is causing the bug. Therefore i'm posting it here as well to make you aware of the problem.

CommentFileSizeAuthor
#2 date-parents_fix-1580032-2.patch674 bytesjmuzz

Comments

jmuzz’s picture

It seems to be a problem related to #field_parents and #parents in date_combo_validate . I don't know if this is the right answer as I don't know the theory and I don't have time to test right now, but I changed the following lines at 454 in date_elements.inc from

  $item = drupal_array_get_nested_value($form_values, $element['#parents']);
  $posted = drupal_array_get_nested_value($form_input, $element['#parents']);

to

  $item = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
  $posted = drupal_array_get_nested_value($form_state['input'], $element['#parents']);

And the dates seem to be getting saved now.

jmuzz’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new674 bytes

I am more confident about this change now. I have looked more at the values of #parents and #field_parents and it looks like #parents always includes the elements from #field_parents plus a few more that identify the field itself.

The current code works on dates directly in the top level of an entity since #field_parents is empty and #parents just has info about the field, but when a date is inside a field collection it breaks because it assumes that #parents will still only have info about the field itself when it actually contains all the info from #field_parents as well.

I have tested this fix on a date inside a field collection and a date nested a level deeper than that inside another field collection.

Status: Needs review » Needs work

The last submitted patch, 2: date-parents_fix-1580032-2.patch, failed testing.

jmuzz’s picture

Version: 7.x-2.0-rc2 » 7.x-2.x-dev
jmuzz’s picture

Status: Needs work » Needs review
podarok’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs tests

#2 looks good for me
good to see here test

vijaycs85’s picture

Status: Reviewed & tested by the community » Active

Committed c4c0522 and pushed to 7.x-2.x. lets add test cases now.

krystlc’s picture

#2 worked for me too~

vijaycs85’s picture

Status: Active » Fixed

Lets add testcase as sepate issue then

Status: Fixed » Closed (fixed)

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