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!
Comment | File | Size | Author |
---|---|---|---|
custom_breadcrumbs_error_message.patch | 892 bytes | Vallenwood | |
Comments
Comment #1
Jody LynnI 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.
Comment #2
NaX CreditAttribution: NaX commentedI 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.
Ether fix should work; it does not really matter as long as the user sees an error message.
Comment #3
MGN CreditAttribution: MGN commentedCommitted to 5.x-1.x-dev.