#34257: ForeignKeyRawIdWidget doesn't include vForeignKeyRawIdAdminField class 
when
custom class passed in attrs
-------------------------------------+-------------------------------------
     Reporter:  Kevin Marsh          |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  contrib.admin        |                  Version:  dev
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:
  widget,admin,raw_id_fields         |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Kevin Marsh):

 Replying to [comment:1 Mariusz Felisiak]:

 Thanks Mariusz, hopefully at least this ticket will serve as instructions
 for others about how to ensure the JS in the widget still works when
 adding additional classes (although is at risk of breaking if
 `vForeignKeyRawIdAdminField` is ever renamed in a new version of Django).

 > As far as I'm aware, attributes passed in attrs override default values
 for all widgets

 Not sure that's entirely true, eg. I think something like
 `FilteredSelectMultiple` just ignores any "class" attr:

 {{{
 class FilteredSelectMultipleWidgetTest(SimpleTestCase):
     #... rest of existing test class
     def test_render_ignores_additional_attrs(self):
         # This widget ignores any class override in `attrs`
         w = widgets.FilteredSelectMultiple("test", False, attrs={"class":
 "myAdditionalClass"})
         self.assertHTMLEqual(
             w.render("test", "test"),
             '<select multiple name="test" class="selectfilter" '
             'data-field-name="test" data-is-stacked="0">\n</select>',
         )
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34257#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070185bbe61526-808f9f3d-3814-4ff8-875b-31ee4a553bb5-000000%40eu-central-1.amazonses.com.

Reply via email to