0

I have a multifield field_staff_required of unlimited cardinality containing two subfields: field_staff_category and field_staff_quantity.

Example: I have an event node containing the staff_required multifield to which I add the following values:

Category: Manager / Qty: 1

Category: Steward / Qty: 5

Category: Security / Qty: 3

On saving the node I would like it to automatically generate new 'staff booking' nodes for each of the staff required. The staff booking node will contain a 'Staff_category' field which would be auto populated with the category from the multifield, and an entity reference field to refer each staff booking node back to the event node.

So the result in the example above is that I end up with 9 new nodes created, one with category set to Manager, five set to Steward, and three set to Security, all referring back to the event node.

Can the above be achieved using Rules? The multifield subfields don't seem to be accessible to Rules. I assume it will be necessary to write a custom module to achieve this. Any suggestions gratefully received!

1

I managed to solve this by swapping the Multifield for a Double Field which does play nicely with Rules.

I was then able to use Rules Action: generate a list from an integer to loop through the quantity for each category and create a new node for each, populating the required fields.

The only downside is that Double Field does not allow to populate a select list from a taxonomy vocabulary, and I could not get the Field Remove Item or Multiple Fields Remove Button modules to work with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.