﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34257	ForeignKeyRawIdWidget doesn't include vForeignKeyRawIdAdminField class when custom class passed in attrs	Kevin Marsh	nobody	"I had a situation where I wanted to add an extra class to the `ForeignKeyRawIdWidget` widget. I noticed that doing something like:

{{{
attrs = {""class"": ""myAdditionalClass""}
widget = ForeignKeyRawIdWidget(rel, admin_site, attrs=attrs)
}}}

resulted in the widget not having the required `vForeignKeyRawIdAdminField` class since under the hood `ForeignKeyRawIdWidget.get_context` does something ''like:''

{{{
context[""widget""][""attrs""].setdefault(""class"", ""vForeignKeyRawIdAdminField"")
}}}

meaning the rendered `<input />` looks like:
{{{
<input class=""myAdditionalClass"" ...
}}}

instead of:
{{{
<input class=""myAdditionalClass vForeignKeyRawIdAdminField"" ...
}}}

----

Note that this same issue applies to the `ManyToManyRawIdWidget` and corresponding `vManyToManyRawIdAdminField` class.

----

I'm not sure if `ForeignKeyRawIdWidget`/`ManyToManyRawIdWidget` is meant to be public, but it'd be nice if we could resolve this in the source. Currently I can work around this by simply doing:
{{{
attrs = {""class"": ""myAdditionalClass vForeignKeyRawIdAdminField""}
widget = ForeignKeyRawIdWidget(rel, admin_site, attrs=attrs)
}}}

I can create a PR based on a similar solution in the patch (and also fix `ManyToManyRawIdWidget`) if this gets accepted."	New feature	closed	contrib.admin	dev	Normal	wontfix	widget,admin,raw_id_fields		Unreviewed	0	0	0	0	0	0
