WebAIM - Web Accessibility In Mind

E-mail List Archives

Forms that delete something

for

From: Laurence Hughes
Date: Jan 8, 2024 1:49PM


Hi,

My company’s web app is written in Ruby on Rails. As a developer, when you
want to let the user delete something (from the database), a common
approach is to use the Rails `button_to‘ method. As a developer you pass
into this method some text for a button and a URL for a server resource
which will handle deleting the data. In terms of rendered HTML, the method
generates a form set to use the POST method and to submit to the URL you
provided. The form includes a button of type ‘submit’ and no other form
elements except a hidden input which tells Rails to perform an HTTP DELETE
rather than a POST.

As a sighted user, all I see is a button.

I see some benefits to this pattern. Developers have, for a long time,
misused links (with the help of JavaScript) to enable deletion, and this
isn’t good. As we know, links are for a different purpose, and using a link
for an unintended purpose breaks user expectations.

But while I’m sure that a link is the wrong tool for the job of deleting
something from a database, I’m also not 100% sure whether a form, that only
includes a single element (a button), is the right interface to present.
The user isn’t really “inputting” anything, either to add, edit or search,
so is a form OK here?

Would this feel weird to a screen reader user? A form with no other
elements except a button that says “Delete xyz”? Or am I being silly and
this is perfectly normal, and is the expected/conventional way to provide a
“Delete xyz” interface accessibly?

Thanks in advance for any advice!
Laurence