2

I'm working on a custom compound field that includes a text value and an entity reference id. The field will contain multiple values, so the widget needs to provide "add new value" functionality, and a way to remove values already added (i.e. a "remove" button).

Following the (older) thread here: https://drupal.org/node/1143880, it seems that "add new value" is provided automatically, but not "remove" existing values? Is that still the case?

The thread above also links to a sandbox project here: https://drupal.org/sandbox/daggerhart/1363702. I tried this code, and it does seem to work, although the formatting is a little different.

What's the current best practice for adding a "remove" button to an unlimited value field widget?

Edit: here is a link to a feature request for this functionality in D8: https://drupal.org/node/1038316

3

there are two modules already

  1. Multiple Fields Remove Button
  2. Field Remove Item
  • +1 for both of these, especially Multiple Fields Remove Button, which implements the standard 'Remove' button functionality that is used for some other multi-value field widgets like File/Image fields. – geerlingguy May 18 '15 at 22:24
0

For now, I'm using a sandbox project called "unlimitedfield_remove", available here: https://drupal.org/sandbox/daggerhart/1363702. The code is working fine, but the formatting of the remove button is a little different than the standard (I haven't looked into why that is).

After you install the unlimitedfield_remove module, you need to select which unlimited value fields should get a remove row button.

I'd still like to confirm a current best practice, so I'd be interested in other approaches.

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.