Skip to content

Commit

Permalink
fix bug: allow forms that have AutoCompleteSelectMultipleField to spe…
Browse files Browse the repository at this point in the history
…cify its own widget. That way a AutoCompleteSelectMultipleWidget can be specified in the form declaration, along with customizations like placeholder attribute.
  • Loading branch information
taivo committed Jun 2, 2012
1 parent 9ef04a9 commit a24dc27
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ajax_select/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ def __init__(self, channel, *args, **kwargs):
# if using in a normal form then set to True so the widget shows help
show_help_text = kwargs.pop('show_help_text',False)

kwargs['widget'] = AutoCompleteSelectMultipleWidget(channel=channel,help_text=help_text,show_help_text=show_help_text)
# if user did not specify own widget, use ajax_select default
kwargs['widget'] = kwargs.get('widget', AutoCompleteSelectMultipleWidget(channel=channel,help_text=help_text,show_help_text=show_help_text))
kwargs['help_text'] = help_text

super(AutoCompleteSelectMultipleField, self).__init__(*args, **kwargs)
Expand Down

1 comment on commit a24dc27

@crucialfelix
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I think this opens it to breaking. the entire app is basically this widget, so if you feel that you have to replace the widget then you've just replaced the app.

if you've replaced the widget, then why not just replace the field ? you would have to do everything manually like set the channel, help text etc.

if its things like extra attributes or classes that you want then it would make better sense to offer an attribute dict that can be used.

already the template can be customized so you can choose to place any html you like.

so I'd like to pass on this addition, but if you want to offer a way to set custom attributes (placeholder would indeed be useful) then I'm quite open to this

Please sign in to comment.