When creating a rule of with only the "After updating existing content" event. Rules presents the option to select the fields from before they are modified. Which is great for creating actions that are based on how the content was changed. The problem is though that field collection does not seem to support this. Any Loops created with node-unchanged:field-collection are completely empty and don't run.

Any insights would be greatly appreciated.

Comments

rbrownell’s picture

Category: support » bug
jlstrecker’s picture

Issue summary: View changes

At 7.x-1.0-beta11, the problem I am seeing is that node-unchanged:field-collection is identical to node:field-collection.

For example:

  1. Create a content type with a field collection that contains an integer field.
  2. Create an "After updating existing content" rule for that content type.
  3. Add a "Show a message on the site" action that prints the integer field attached to node:field-collection and node-unchanged:field-collection.

The printed value for node-unchanged is wrong. It shows the changed value.

I am able to loop over node-unchanged:field-collection, but also there it shows the wrong values.

jlstrecker’s picture

The reason that node-unchanged and node both show the same (new) field collection values is that the node stores a reference to the field collection. The field collection is a separate entity. Changes to it can be caught by the rules events for field collections. The "after updating an existing field collection item" event gives the correct unchanged and new values.

ultrabob’s picture

Category: Bug report » Feature request

My most common use case for field collections is when I need to collect several instances of a set of values. (i.e. Collect Family and Given name for a number of people).

If I then want to find out if any people have been added (and there is the chance that people have been removed) there is no way for me to use rules to react to this because each set of Family and Given names will be one field collection instance. The only possible solution now seems to be to maintain a hidden field that is a list of the people on the node, then upon node save, compare the the values of the list with the values in the field collections before updating the hidden field.

I don't know if it is even possible (I guess maybe not), but it would sure be nice if field collections was able to provide the prior version of the field-collection to node-unchanged and the current version to node.

ultrabob’s picture

Version: 7.x-1.0-beta5 » 7.x-1.x-dev