Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug: AutoCompleteSelectMultipleField does not honor 'widget' parameter #14

Closed
taivo opened this issue Jun 2, 2012 · 6 comments
Closed

Comments

@taivo
Copy link

taivo commented Jun 2, 2012

AutoCompleteSelectMultipleField overwrites its kwargs['widget'] with its default AutoCompleteSelectMultipleWidget so there it's not possible to customize the widget in your form definition.

This seems to be a bug since the other ajax-select fields: AutoCompleteSelectWidget and AutoCompleteField both allow substituting the default widget with your own, just like django. Widget substitution is useful especially when you want to change placeholder attribute or CSS attributes of the default widget.

I have fixed it in this commit taivo@a24dc27 but not sure how to submit a second pull request since I've already have one in the pipeline.

Last but not least, I find this package to be extremely useful. I wasted a lot of time getting autocomplete done on an adhoc basis, and even more time trying generalize all the adhoc code. Good thing I found ajax-select before going too far into reinventing the wheel. So thanks for maintaining this tool!

@crucialfelix
Copy link
Owner

I left a comment on the commit.

I wouldn't describe this as a bug, since the main feature of the field is to work with its own tightly integrated widget.

customizations like setting placeholder or css attributes should be done another way, not by changing the entire widget. the widget is the core of the application. I think there is a simpler way to accomplish what you want to do, and letting a custom widget get passed in basically breaks the application.

@taivo
Copy link
Author

taivo commented Jul 14, 2012

Hi, good to see the surge of activities in this branch :)
I haven't thought much about this issue since I last put in a pr. Just re-reading my own comment and yours though, it looks like AutoCompleteSelectWidget and AutoCompleteField already allows widget override. That means they have the same vulnerability to breakage. So if we opt for no widget override (and just add a placeholder parameter to the __init__ methods), it would be a good idea to make sure that choice is consistent across all three widgets.

For my usage, I wanted the flexibility of extending the widgets and substitute them so the widget override option worked better for me. I'd be happy to put in placeholder-only support though and put in a pr when I can find some time. Thanks for maintaining this package.

@crucialfelix
Copy link
Owner

an attributes dict would be the best. then it could be used for all kinds of things like data-something="something"

@qrilka
Copy link

qrilka commented Apr 20, 2015

@crucialfelix
Copy link
Owner

That's a four year old fork with all the licensing information removed.

Django widgets already support attrs={'placeholder': 'Placeholder Text'}

so there is no need for a special hook.

https://docs.djangoproject.com/en/1.8/ref/forms/widgets/

widget is supported so you can create the widget with any attrs you want
including class, autofocus, disabled, maxlength etc.

http://www.w3schools.com/tags/tag_input.asp

maybe including a widget_attrs argument just like plugin_options would be a
good feature.

On Mon, Apr 20, 2015 at 11:43 AM Kirill Zaborsky [email protected]
wrote:

Did you thought about adding something like
Polyconseil/django-ajax-selects@bccbcde
https://github.com/Polyconseil/django-ajax-selects/commit/bccbcde7dea5170eeaf5749a3307b4639b58db8f
?


Reply to this email directly or view it on GitHub
#14 (comment)
.

@qrilka
Copy link

qrilka commented Apr 20, 2015

Yes, that was the point - I don't see how could I set placeholder with e.g. make_ajax_field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants