django-fluent / django-fluent-comments

A modern, ajax-based appearance for django comments
https://django-fluent.org/
Apache License 2.0
182 stars 90 forks source link

Comment form errors are not shown for bootstrap > 3 #129

Open ephes opened 1 year ago

ephes commented 1 year ago

Hi,

thanks for this cool project! I'm using it for my Python Podcast site for example and it works great. But yesterday I got a complaint that the comments were not working. The problem was that the error messages for the comment form were not shown. And this was caused by me using bootstrap > 3 😬. There's some code in ajaxcomments.js modifying the classes to remove the display: none added by default to an element having the invalid-feedback class:

                $field.after('<span class="js-errors">' + data.errors[field_name] + '</span>');
                $field.closest('.control-group').addClass('error');  // Bootstrap 2
                $field.closest('.form-group').addClass('has-error'); // Bootstrap 3

Maybe it's possible to add a line for Bootstrap 4 and 5, too? This line here might be enough:

$field.removeClass('is-valid').addClass('is-invalid');

And the structure of the html has to be modified a little bit so that the error span is a direct silbling of the input field.

I just add a small css workaround for my own projects so it's not super important. Have a nice day!

best regards Jochen