When you add more than one set of fields grouped as a multiadd item you currently get a single remove button at the bottom of the list next to the add button that allows you to remove one from the list. You don't get to choose which one though, it just pops the last element off the end of the list. It would be better if you could choose to remove a specific item (set of fields & their corresponding values) from the list instead.

Comments

eojthebrave’s picture

Status: Active » Needs review
StatusFileSize
new7.36 KB

And here is a patch. Adds a remove button to each set of multiadd fields when there is more than one of the given set of fields.

Question. Should we have the ability to remove the "last" set of fields. Should there be a remove button if there is only one set of fields? Maybe in that case it just blanks the values for those fields?

sidharth_k’s picture

This patch is awesome Joe! We needed this functionality!

Have been busy with the rest of the candidate application since I got back Monday. Will review and merge soon.

sidharth_k’s picture

The logic is okay and this works properly for normal drupal forms. Unfortunately it seems to fail for ctools multistep forms.

Unfortunately some caching (or something else?) seems to be happening. While #default_value is correct the #value is always the old one.

multiadd_process returns the correct $element. But somewhere in the form processing chain something is going wrong. I'm trying to modify the code a bit to get this to work but no luck yet.

sidharth_k’s picture

Assigned: Unassigned » sidharth_k
Status: Needs review » Fixed

Committed in http://drupalcode.org/sandbox/sidharth_k/1349098.git/commit/75a3e5b

Thanks again Joe!

Related commits:
- Remove button per item should now work on ctools multistep forms
http://drupalcode.org/sandbox/sidharth_k/1349098.git/commit/037bcb6
- Remove the multiadd_remove button during submit phase This is so that the button values don't get persisted when the multiadd values are serialized
http://drupalcode.org/sandbox/sidharth_k/1349098.git/commit/25ae73d

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.