On line 166, the custom_breadcrumbs_form_validate function appears, and it throws an error when you don't have the same number of entries in the "titles" box as the "paths" box. However, the code for form_set_error is incorrect, and so the error is never displayed; it simply refreshes the edit screen and no new breadcrumb (or edited breadcrumb) is created. form_set_error requires that the first argument be the actual form field the error relates to (so Drupal knows which one to outline in red).

Solution is in the attached patch. The manual version is to cut the function starting at line 166:

function custom_breadcrumbs_form_validate($form_id, $form_values) {
  $path_count = count(explode("\n", $form_values['paths']));
  $title_count = count(explode("\n", $form_values['titles']));
  if ($title_count != $path_count) {
    form_set_error(t('Every link path must have a matching title. There are !paths paths, and !titles titles.', array('!paths' => $path_count, '!titles' => $title_count)));
  }
}

and replace it with:

function custom_breadcrumbs_form_validate($form_id, $form_values) {
  $path_count = count(explode("\n", $form_values['paths']));
  $title_count = count(explode("\n", $form_values['titles']));
  if ($title_count != $path_count) {
    $error_field = ($title_count > $path_count) ? 'paths' : 'titles';
    form_set_error($error_field,t('Every link path must have a matching title. There are !paths paths, and !titles titles.', array('!paths' => $path_count, '!titles' => $title_count)));
  }
}

Problem solved. As you can see, it decides which field to outline in red by deciding which of the two textareas has fewer lines entered. That one gets the "error" designation. Enjoy!

CommentFileSizeAuthor
custom_breadcrumbs_error_message.patch892 bytesVallenwood
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jody Lynn’s picture

Status: Needs review » Reviewed & tested by the community

I got the same problem because I accidentally had a blank line at the end of one of the lists. As a result the form did nothing at all.

NaX’s picture

Priority: Normal » Critical

I fixed this on one of my sites by adding a blank field. Because the form is so simple it really does not need to show the field that has the problem and because the two fields are related they should ether both be highlighted or nether should be highlighted.

I think this is a critical problem and needs to be fixed. If I did not know PHP I would not be able to use this module because I had no idea that there was a problem until I looked at the code.

form_set_error('', t('Every link path must have a matching title. There are !paths paths, and !titles titles.', array('!paths' => $path_count, '!titles' => $title_count)));

Ether fix should work; it does not really matter as long as the user sees an error message.

MGN’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5.x-1.x-dev.

Status: Fixed » Closed (fixed)

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