﻿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
13674	"Javascript for adding inline fields doesn't update ""for"" attribute in label"	Jonas von Poser	Tay Ray Chuan	"I do some checking for required fields using Javascript in the admin. Doing that, I noticed that adding inline fields doesn't update the ""for"" attribute for the new <label> fields. If the field is called ""image"", the newly added field label looks like this:

{{{
<label class=""required"" for=""id_images-__prefix__-image"">Image:</label>
}}}

This is the patch that solved it for me:

{{{
diff --git a/django/contrib/admin/media/js/inlines.js b/django/contrib/admin/media/js/inlines.js
index cf79023..90b50b5 100644
--- a/django/contrib/admin/media/js/inlines.js
+++ b/django/contrib/admin/media/js/inlines.js
@@ -75,6 +75,14 @@
                                    }).each(function() {
                                        var el = $(this);
                                        el.attr(""name"", el.attr(""name"").replace(/__prefix__/g, nextIndex));
+                                   })
+                                   .end()
+                                   .filter(function() {
+                                       var el = $(this);
+                                       return el.attr(""for"") && el.attr(""for"").search(/__prefix__/) >= 0;
+                                   }).each(function() {
+                                       var el = $(this);
+                                       el.attr(""for"", el.attr(""for"").replace(/__prefix__/g, nextIndex));
                                    });
                                if (row.is(""tr"")) {
                                        // If the forms are laid out in table rows, insert
}}}"		closed	contrib.admin	1.2		fixed	admin		Ready for checkin	1	0	0	1	0	0
