﻿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
10131	"When using an m2m with raw_id_fields, ""add another"" pop-up replaces field value instead of appending to list"	onemoreryan@…	nobody	"When adding m2m relationships to a record via raw_id_field, selecting an existing object from the database works as expected - appending the new ID to a comma-separated list inside the INPUT element. However, when using the admin pop-up's ""Add another"" function, the m2m field value is not appended to, but overwritten.

Example use: A !PhotoSet model has an m2m to a Photo model, using raw_id_field. When creating a !PhotoSet, the user should be able to create and upload new Photo records on the fly via the raw_id_field's pop-up form. The ID for each Photo thus created should append to the list in !PhotoSet, but instead each new ID just overwrites the old value.

I believe the problem is in /contrib/admin/js/admin/RelatedObjectLookups.js. The dismissRelatedLookupPopup function (called when user selects an existing record) checks for vManyToManyRawIdAdminField, and appends if there's already a value there. But the dismissAddAnotherPopup function simply replaces the value of the INPUT element. Locally, this problem seems to be fixed by wrapping that same vManyToManyRawIdAdminField check inside the dismissAddAnotherPopup IF statement for (elem.nodeName == 'INPUT')."		closed	contrib.admin	1.0		duplicate	m2m, raw_id_fields, javascript		Unreviewed	1	0	0	0	0	0
