Closed (fixed)
Project:
Field collection
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Sep 2011 at 17:42 UTC
Updated:
21 Jan 2012 at 02:00 UTC
Jump to comment: Most recent file
Comments
Comment #1
echoz commentedI’m getting the same (except with the current dev of 12/15, it’s line 1251). The error goes away on reload, and the settings are seemingly saved without issue. It happens set to unlimited or not.
Comment #2
juampynr commentedAfter checking the code logic, it seems that when the field is edited and then saved, a wrong property ($element['_weight']['#value']) is being used for the weight instead of $element['#weight']. I see that this logic was added at http://drupal.org/node/1142114#comment-4968338.
Attached is a patch to fix the issue. I would appreciate a review.
Comment #3
echoz commentedThe patch in #2 resolved the issue for me, that the field collection field can be saved with no error. RTBC?
Comment #4
wjaspers commentedI'm confused.
Why is the #weight handled by the item's 'delta' in the database?
When the field collection's items are saved, does that mean the entire set gets deleted and re-inserted? Is it revision safe?
Comment #5
juampynr commentedI agree, it looks odd because the actual '_weight' index is set when a Field Collection is removed, but not when it is being saved, hence the warning alerting about the undefined index.
Hope that @tim.plunkett can throw in some light.
Comment #6
tim.plunkettDiscussed with juampy in IRC, this is not the right fix. Also, I could not reproduce.
Specific steps to reproduce should be added to the issue summary.
Comment #7
tim.plunkett$element['_weight']is added by field_multiple_value_form(), which is called for multivalue fields when editing content. But, the multiple value form is not used by the default values form when editing the content type, so the easiest way to check this is justisset($element['_weight']).Comment #8
juampynr commentedThe following condition evaluates to TRUE in multivalued fields, causing the warning to occur:
Here is an updated patch where the isset() statement is evaluated first. I splitted it out to a higher level as the line was getting far too long.
Comment #9
tim.plunkettCommitted, thanks!
http://drupalcode.org/project/field_collection.git/commit/fc02cae