diff --git a/django/contrib/admin/media/js/inlines.js b/django/contrib/admin/media/js/inlines.js
index ddaf355..0153a41 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
diff --git a/django/contrib/admin/media/js/inlines.min.js b/django/contrib/admin/media/js/inlines.min.js
index c3336d0..fa3540b 100644
--- a/django/contrib/admin/media/js/inlines.min.js
+++ b/django/contrib/admin/media/js/inlines.min.js
@@ -1,6 +1,6 @@
-(function(a){a.fn.formset=function(g){var b=a.extend({},a.fn.formset.defaults,g),l=function(d,f,e){var c=new RegExp("("+f+"-\\d+)");f=f+"-"+e;a(d).attr("for")&&a(d).attr("for",a(d).attr("for").replace(c,f));if(d.id)d.id=d.id.replace(c,f);if(d.name)d.name=d.name.replace(c,f)};g=a("#id_"+b.prefix+"-TOTAL_FORMS").attr("autocomplete","off");var j=parseInt(g.val()),h=a("#id_"+b.prefix+"-MAX_NUM_FORMS").attr("autocomplete","off");g=h.val()==""||h.val()-g.val()>0;a(this).each(function(){a(this).not("."+
-b.emptyCssClass).addClass(b.formCssClass)});if(a(this).length&&g){var i;if(a(this).attr("tagName")=="TR"){g=this.eq(0).children().length;a(this).parent().append('<tr class="'+b.addCssClass+'"><td colspan="'+g+'"><a href="javascript:void(0)">'+b.addText+"</a></tr>");i=a(this).parent().find("tr:last a")}else{a(this).filter(":last").after('<div class="'+b.addCssClass+'"><a href="javascript:void(0)">'+b.addText+"</a></div>");i=a(this).filter(":last").next().find("a")}i.click(function(){var d=a("#id_"+
-b.prefix+"-TOTAL_FORMS"),f=a("#"+b.prefix+"-empty"),e=f.clone(true);e.removeClass(b.emptyCssClass).addClass(b.formCssClass).attr("id",b.prefix+"-"+j);j+=1;e.find("*").filter(function(){var c=a(this);return c.attr("id")&&c.attr("id").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("id",c.attr("id").replace(/__prefix__/g,j))}).end().filter(function(){var c=a(this);return c.attr("name")&&c.attr("name").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("name",c.attr("name").replace(/__prefix__/g,
-j))});if(e.is("tr"))e.children(":last").append('<div><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></div>");else e.is("ul")||e.is("ol")?e.append('<li><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></li>"):e.children(":first").append('<span><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></span>");e.find("input,select,textarea,label,a").each(function(){l(this,b.prefix,d.val())});e.insertBefore(a(f));a(d).val(parseInt(d.val())+
-1);h.val()!=""&&h.val()-d.val()<=0&&i.parent().hide();e.find("a."+b.deleteCssClass).click(function(){var c=a(this).parents("."+b.formCssClass);c.remove();b.removed&&b.removed(c);c=a("."+b.formCssClass);a("#id_"+b.prefix+"-TOTAL_FORMS").val(c.length);if(h.val()==""||h.val()-c.length>0)i.parent().show();for(var k=0,m=c.length;k<m;k++)a(c.get(k)).find("input,select,textarea,label,a").each(function(){l(this,b.prefix,k)});return false});b.added&&b.added(e);return false})}return this};a.fn.formset.defaults=
-{prefix:"form",addText:"add another",deleteText:"remove",addCssClass:"add-row",deleteCssClass:"delete-row",emptyCssClass:"empty-row",formCssClass:"dynamic-form",added:null,removed:null}})(django.jQuery);
+(function(a){a.fn.formset=function(g){var b=a.extend({},a.fn.formset.defaults,g),l=function(d,f,e){var c=RegExp("("+f+"-\\d+)");f=f+"-"+e;a(d).attr("for")&&a(d).attr("for",a(d).attr("for").replace(c,f));if(d.id)d.id=d.id.replace(c,f);if(d.name)d.name=d.name.replace(c,f)};g=a("#id_"+b.prefix+"-TOTAL_FORMS").attr("autocomplete","off");var i=parseInt(g.val()),h=a("#id_"+b.prefix+"-MAX_NUM_FORMS").attr("autocomplete","off");g=h.val()==""||h.val()-g.val()>0;a(this).each(function(){a(this).not("."+b.emptyCssClass).addClass(b.formCssClass)});
+if(a(this).length&&g){var j;if(a(this).attr("tagName")=="TR"){g=this.eq(0).children().length;a(this).parent().append('<tr class="'+b.addCssClass+'"><td colspan="'+g+'"><a href="javascript:void(0)">'+b.addText+"</a></tr>");j=a(this).parent().find("tr:last a")}else{a(this).filter(":last").after('<div class="'+b.addCssClass+'"><a href="javascript:void(0)">'+b.addText+"</a></div>");j=a(this).filter(":last").next().find("a")}j.click(function(){var d=a("#id_"+b.prefix+"-TOTAL_FORMS"),f=a("#"+b.prefix+"-empty"),
+e=f.clone(true);e.removeClass(b.emptyCssClass).addClass(b.formCssClass).attr("id",b.prefix+"-"+i);i+=1;e.find("*").filter(function(){var c=a(this);return c.attr("id")&&c.attr("id").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("id",c.attr("id").replace(/__prefix__/g,i))}).end().filter(function(){var c=a(this);return c.attr("name")&&c.attr("name").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("name",c.attr("name").replace(/__prefix__/g,i))}).end().filter(function(){var c=
+a(this);return c.attr("for")&&c.attr("for").search(/__prefix__/)>=0}).each(function(){var c=a(this);c.attr("for",c.attr("for").replace(/__prefix__/g,i))});if(e.is("tr"))e.children(":last").append('<div><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></div>");else e.is("ul")||e.is("ol")?e.append('<li><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+b.deleteText+"</a></li>"):e.children(":first").append('<span><a class="'+b.deleteCssClass+'" href="javascript:void(0)">'+
+b.deleteText+"</a></span>");e.find("input,select,textarea,label,a").each(function(){l(this,b.prefix,d.val())});e.insertBefore(a(f));a(d).val(parseInt(d.val())+1);h.val()!=""&&h.val()-d.val()<=0&&j.parent().hide();e.find("a."+b.deleteCssClass).click(function(){var c=a(this).parents("."+b.formCssClass);c.remove();b.removed&&b.removed(c);c=a("."+b.formCssClass);a("#id_"+b.prefix+"-TOTAL_FORMS").val(c.length);if(h.val()==""||h.val()-c.length>0)j.parent().show();for(var k=0,m=c.length;k<m;k++)a(c.get(k)).find("input,select,textarea,label,a").each(function(){l(this,
+b.prefix,k)});return false});b.added&&b.added(e);return false})}return this};a.fn.formset.defaults={prefix:"form",addText:"add another",deleteText:"remove",addCssClass:"add-row",deleteCssClass:"delete-row",emptyCssClass:"empty-row",formCssClass:"dynamic-form",added:null,removed:null}})(django.jQuery);
