I was trying to remove a link from a node and found that I couldn't. Even when I deleted the link text it gave me an error saying I needed to enter something in the URL field. Would it be possible to add a remove button to the edit screen once a link has been added? Something similar to the file upload field?

#12 needs-work.patch4.76 KBdsdeiz


jcfiala’s picture

No, probably not. It's only complaining about needing to enter something in the URL field because of the settings on the field - one of these is probably true:

1) You've got the field on that node type set to required.
2) You've set the field up so that it requires a url if there's a title, and you didn't blank out the title also.

I suspect #1 is the correct answer. If you stop the field from being required, you'll be fine.

bmango’s picture

Thanks very much for the reply. I thought it was strange that I couldn't remove it. I'll try your suggestions. Thanks again.

kennywyland’s picture

Please don't dismiss this request. I would like the Remove button as well. I don't have my Link field set to Required, but if I've got 5 urls in a Link field, I have no way to delete them.

Emptying out all 5 of those values doesn't remove the values, it just makes the field have 5 empty values. That means the node behaves as if it has 5 Link values instead of 0.


mrfelton’s picture

Version:6.x-2.9» 7.x-1.x-dev

I think this is a valid feature request. It would be a big + for usability. Bumping to 7.x

jenlampton’s picture

Issue summary:View changes

I would also like a remove button, for the reason specified in #3.

I've stumbled across three different modules that are all trying to solve this UI deficiency for fields in general:
* the multiple_fields_remove_button module
* the cck_multiple_field_remove module
* the field_remove_item

Maybe one of these will help someone else who finds this issue.

dsdeiz’s picture

Emptying the field works as expected now. I don't think a "Remove" button is still necessary.

heylookalive’s picture

In addition to the comments in post 3, I consider this a UX fail as a remove button per item makes it clear as to how to remove an item. Blanking fields out is obscure and not intuitive.

jcfiala’s picture

Well, what field modules do provide a blanking button?

"Blanking fields out is obscure and not intuitive."

It seems to be the way that fields are constructed in core, and I tend to be willing to follow them as an example. That being said, I'd be willing to review a patch if someone wants to create one.

How is this issue handled in Drupal 8, by the way?

MrPaulDriver’s picture

Well, what field modules do provide a blanking button?

File - for one.

Ordinary folk don't get it, that they have to blank out the text. A remove button is very necessary.

heylookalive’s picture

@jcfiala Core does many things :) I can't say that this is a priority for me in terms of patching, but will help however else I can (reviewing or whatever).

dsdeiz’s picture

Assigned:Unassigned» dsdeiz

I'll try my hands on this. I took a look at the options from the existing modules posted at #5. multiple_fields_remove_button provides a really good UX since it adds a 'Remove' button on each item in the form. I'll try to borrow some code there and see if I can get it to work.

dsdeiz’s picture

Assigned:dsdeiz» Unassigned
new4.76 KB


So I gave this a try. I used exactly the same code as from the multiple_fields_remove_button module (literally copied) specifically from here. I'm not entirely sure how this should be handled i.e. taking code from another module. I also tried removing some parts of it though it looks like it works exactly with the same code.

I haven't finished it but I think I'm close. There's something that's blocking me though. My AJAX callback is this:

 * Callback to rebuild the form for AJAX.
function link_remove_callback($form, &$form_state) {
$key = $form_state['triggering_element']['#array_parents'][0];

$commands = array();

$commands[] = ajax_command_replace('#' . $form[$key]['#id'], drupal_render($form[$key]));
$commands[] = ajax_command_prepend('#' . $form[$key]['#id'], theme('status_messages'));

  return array(
'#type' => 'ajax', '#commands' => $commands);

$form[$key]['#id'] becomes #edit-field-name--1 since I think the form has already been processed and having the id already existing for #edit-field-name thus not being able to replace the correct element. Changing $form[$key]['#id'] with something like #edit-field-name works although it only works the first time you replace the whole widget.

I've attached the patch for anyone who can help me out.