I've just realised that in the use case I am working towards, it makes way more sense to the user if the choice made in the modal overwrites all previously-selected items on the form (instead of adding to them).

It's actually quite simple to add this possibility to this module by adding an extra option for it and tweaking the behaviour/wording at key points. Is this a piece of functionality you can see being in this module?

Patch to follow, so you can see what I mean.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jamsilver created an issue. See original summary.

jamsilver’s picture

Patch attached.

It adds a new field widget setting:
New Replace all items on submit checkbox

It also adds a new views field option:
New Pre-tick if already selected views field configuration

When both are ticked you get a fully working replace workflow.

jamsilver’s picture

Oh, sorry - left a debug line in that one. New patch attached.

jsacksick’s picture

Hey jamsilver, I added you as a co-maintainer, feel free to commit it. I'm wondering about having two buttons (one for adding the items, the other one for replacing), what do you think?

jamsilver’s picture

New patch added with the following bugs fixed:

1. Cannot use a different "Choose/Replace" button label when a value is already selected or not as this breaks subsequent ajax requests (Drupal uses the form button value to determine what the triggering element is),
2. Fixed an issue whereby the boxes would become un-checked when the user interacted with any exposed filters. The new patch now embeds the settings/selected_Items in a hidden element in the exposed form, in the same was as is being done in the wider modal form.

I added you as a co-maintainer, feel free to commit it

Cool - thanks for that. I'll let it run a bit in the wild to catch any more bugs, and commit when RTBCed

I'm wondering about having two buttons (one for adding the items, the other one for replacing), what do you think?

This is an interesting idea. The patch I've added gives the choice to the site-builder - essentially forcing the content-admin to use either the Add item workflow or the Replace item workflow. This is what I want for my use case here. However, there is probably a use case for exposing both approaches to the user.

I wonder if what we need is a slight revamp of the field settings, to make it clear to the site-builder that they are choosing one of (or both of) two different workflows?