Allow to remove field items with a button

Created on 24 November 2023, about 1 year ago
Updated 1 May 2024, 9 months ago

Problem/Motivation

SAM is great for allowing you to add items one by one without a clunky interface.
But what when you want to remove one item?

An experienced user knows that clearing the fields so Drupal considers it "empty" allows you to remove an item. But it's not obvious and, with complex widgets, it's tedious.

So let's add an explicit "Remove" button to remove one item.

Proposed resolution

Add a "Remove" button via JS that clears the widget and hides it.

Background

I tried first to integrate with https://www.drupal.org/project/multiple_fields_remove_button , but sadly wasn't able to.
That module takes care of it server-side, but the button they add does everything in an ajax callback. I couldn't find a way to react to those changes while ensuring the "Remove" button triggered them.

So ended up including it client-side in SAM.

Remaining tasks

Patch, review, discuss.

User interface changes

A "Remove" button is added.

API changes

TBD

Data model changes

TBD

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024