Skip to content

Commit

Permalink
newforms-admin: Fixed #6202 -- FilteredSelectMultiple is now wrapped …
Browse files Browse the repository at this point in the history
…with RelatedFieldWidgetWrapper to display the add button.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7195 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
brosner committed Mar 5, 2008
1 parent fb3994b commit dac6f2d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions django/contrib/admin/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,6 @@ def formfield_for_dbfield(self, db_field, **kwargs):
If kwargs are given, they're passed to the form Field's constructor.
"""
# For ManyToManyFields with a filter interface, use a special widget.
if isinstance(db_field, models.ManyToManyField) and db_field.name in (self.filter_vertical + self.filter_horizontal):
kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical))
return db_field.formfield(**kwargs)

# For DateTimeFields, use a special field and widget.
if isinstance(db_field, models.DateTimeField):
kwargs['form_class'] = forms.SplitDateTimeField
Expand All @@ -176,9 +171,12 @@ def formfield_for_dbfield(self, db_field, **kwargs):
if isinstance(db_field, models.ForeignKey) and db_field.name in self.raw_id_fields:
kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel)
else:
if isinstance(db_field, models.ManyToManyField) and db_field.name in self.raw_id_fields:
kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel)
kwargs['help_text'] = ''
if isinstance(db_field, models.ManyToManyField):
if db_field.name in self.raw_id_fields:
kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel)
kwargs['help_text'] = ''
elif db_field.name in (self.filter_vertical + self.filter_horizontal):
kwargs['widget'] = widgets.FilteredSelectMultiple(db_field.verbose_name, (db_field.name in self.filter_vertical))
# Wrap the widget's render() method with a method that adds
# extra HTML to the end of the rendered output.
formfield = db_field.formfield(**kwargs)
Expand Down

0 comments on commit dac6f2d

Please sign in to comment.