yourlabs / django-autocomplete-light

A fresh approach to autocomplete implementations, specially for Django. Status: v4 alpha, v3 stable, v2 & v1 deprecated.
https://django-autocomplete-light.readthedocs.io
MIT License
1.8k stars 468 forks source link

django-bootstrap3's bootstrap_form templatetag breaks form submission due to "required" attribute #325

Closed soult closed 9 years ago

soult commented 10 years ago

I am using the autocomplete light extension with the django-bootstrap3 extension.

When I use the bootstrap_form templatetag instead of the usual form.as_p or similar, the boostrap extension adds a "required" attribute to the input HTML tag. Browsers that support the tag will then not let me submit the form.

My current workaround is to manually set the is_required attribute to False for all autocomplete widgets. You can see the check used by django-bootstrap3 here.

Do you think it would be useful to automatically set the is_required attribute on all autocomplete widgets?

jpic commented 10 years ago

It's a good idea to have is_required which is a new standard.

If you're in a hurry, be sure that such a pull request will be accepted: https://github.com/django/django/commit/bc21e9c0d9253f9d49a0063830a645d1c724c696

Thanks

soult commented 9 years ago

The problem is that the Django Bootstrap3 app already sets the required attribute. I have created a small example app to demonstrate the problem: https://github.com/soult/django-autocomplete-light/tree/issue-325

If you run the app, try entering an animal (start with 'ca' or 'do'), then select it. The Autocomplete Light JavaScript will remove the "ca" string from the "#id_animal-autocomplete" input element and add "cat" to the "#id_animal" select element. But because "#id_animal-autocomplete" has the "required" attribute set by the Bootstrap3 app, you can not submit the form.

jpic commented 9 years ago

Does this work for you ?

$('#id_animal-autocomplete').removeAttr('required')
jpic commented 9 years ago

Any feedback ? please reopen ;)