If a field can have unlimited values, Drupal adds an empty field after the last completed field on the node or entity edit page.
But if you are using the field collection embedded widget with a field collection that has unlimited values and contains a field with a default value, the field collection thinks that a user has entered content and will add a new field collection on entity save. So each time you edit a node that contains an unlimited field collection that contains a field with a default value, a new field collection will be added to the node.
Field collection needs a way to contain fields with default values and not create new collections unless the user wants it to.
- Make a content type
-- Add a field collection
-- -- with
-- -- and
field_trackto use the embedded widget, and contain unlimited values.
field_artista default value of "Mozart".
- Create a new
field_song_namevalues (for example, "Beethoven" and "Für Elise")
Save the node.
- Now edit the node, and save it without changing anything.
A playlist with one track: "Beethoven" and "Für Elise".
A playlist with two tracks: "Beethoven" and "Für Elise", and a second with the default artist "Mozart" and no song name.
field_default_form() checks to see if the entity is new before populating the default values. However, even when editing an existing playlist, each new track is considered a new entity, and its fields are populated with default values.
Find a way to trick
field_default_form() into not firing for field collection items, at least when using the embedded widget.
Fix the problem :).
User interface changes
|FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch field_collection_embedded.patch. Unable to apply patch. See the log in the details link for more information.|
|FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch field_collection-1239946-153-rollback.patch. Unable to apply patch. See the log in the details link for more information.|
|FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch field_collection-1239946-125.patch. Unable to apply patch. See the log in the details link for more information.|
|PASSED: [[SimpleTest]]: [MySQL] 77 pass(es).|