makinacorpus / django-leaflet

Use Leaflet in your Django projects
GNU Lesser General Public License v3.0
717 stars 283 forks source link

Update widget.html to add {{class}} context variable to input class #335

Closed jameelhamdan closed 3 years ago

jameelhamdan commented 3 years ago

Add class context variable to template to enable adding custom classes to input

Gagaro commented 3 years ago

Hi,

Thanks for the PR, though I guess you also have a customized widget to make it work?

If that's the case, you can overwrite the template in your own app by creating a template with the same path and placing your app before django-leaflet in your INSTALLED_APPS.

jameelhamdan commented 3 years ago

Yes I have customized the template to make it work in my project, but in the default django widgets specifying the class in attrs kwarg is expected to add that class to the input tag, so i added support for that in this pull request

Gagaro commented 3 years ago

What I meant is that class is not in the context data of this template by default, you probably modified the class as well? In that case, just merging the template without modifying the class has no sense.

jameelhamdan commented 3 years ago

@Gagaro this pull request also solves issue where django's is-invalid error css class is not appended to element class, and validation message under field does not show under field.

Gagaro commented 3 years ago

All right then :+1: