Field collections containing many fields and allowing multiple values can create considerable clutter on the parent node edit form when using the embedded widget. At a certain level of complexity, you start to see the benefit of the UI that the hidden widget provides.

But there are problems with revisioning workflows when using the hidden widget - see http://drupal.org/node/1031010#comment-5376576

I'd like the option to use the hidden widget behaviour on the node edit form, not the node view - instead of hiding the field collection subform elements, display the formatter output, with appropriate add/delete/edit links. These take the user to the field collection create/edit form, and saving that takes them back to the parent node-edit form. This would allow normal revisioning workflows for the parent node.

This could save considerable space on the parent form, and would allow revisioning workflow modules to do their thing. It could also be very logical for the user to present the field collection subform in an overlay.

CommentFileSizeAuthor
#2 linked-field-widget-1374138.patch7.02 KBJohn Pitcairn
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

John Pitcairn’s picture

This might be reasonably simple to implement. I'm working on a patch to provide:

A new field collection view mode, "edit".
A new field collection form widget, "linked".

In the parent edit form, the widget should display themed output for the field collection according to the configuration of the "edit" view mode. So you can display any combination of fields from the field collection, in any order.

If the user has appropriate privileges, each field collection item should have an "Edit" link.
For multiple-value field collections, "Remove" and "Add another item" buttons should be available.

John Pitcairn’s picture

Here's a highly experimental patch that supplies a new view mode, "parent form", and a new field widget, "linked". There's probably a lot wrong with this. Changes are in field_collection_field_widget_info() and field_collection_field_widget_form().

Select the "linked" widget for the field collection instance in the parent content type "manage fields".
Configure the "parent form" view mode in the field collection "manage display".

The parent edit form will display non-editable fields from the field collection as configured, with appropriate edit/delete/add links. The default "add another" button is hidden. For multi-value fields, this setup probably works best if the patch from #1239946: Embedded field collection items with a default value result in new items on save is applied to remove the default empty item.

The edit/delete/add links are really crying out to be presented in some kind of modal overlay for better UX, otherwise if the user clicks those links after editing other fields their edits will be discarded. Since the core overlay behaviour seems inextricably linked with admin paths and the admin theme, I think it unlikely that will work. So any modal implementation will probably add a contrib module dependency and make it desirable to spin this whole modification off into a separate module.

John Pitcairn’s picture

Status: Active » Needs review

>> needs review

tim.plunkett’s picture

Status: Needs review » Needs work

Can you rewrite this purely as an addition, and not touching the existing widget code?

It can be refactored later, but right now the switch/case fallthrough and the moving of the $recursion code is scary.

thirdboxcar’s picture

I would find this Linked widget incredibly useful. However, implementing the patch as-is eats all the existing data in my Field Collections on Save, which isn't ideal, to say the least :)

I also get the following error: Notice: Undefined index: add in field_collection_field_formatter_links() (line 901 of /sites/all/modules/field_collection/field_collection.module).

John Pitcairn’s picture

I'm not actively using this at present, though I may do further work on it in future, and will do as requested if so. If anyone else wants to rewrite it before then, please go ahead.

thirdboxcar’s picture

I would find this incredibly useful (and am not advanced enough to write this plugin myself), just to express interest.

timb’s picture

Issue summary: View changes

I too would like to see this. Currently I am letting the user use a wysiwyg inside the collection, but once you get 50 wysiwyg on a screen, things get messy.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: linked-field-widget-1374138.patch, failed testing.