From 1ace912f7e1916e03bc91ef91318803817d6a72e Mon Sep 17 00:00:00 2001 From: Julien Phalip Date: Sat, 16 Jun 2012 14:29:41 -0700 Subject: [PATCH] Fixed #18477 -- Fixed colspan value when a TabularInline form contains validation errors. Thanks to yedpodtrzitko for the report and patch. --- django/contrib/admin/static/admin/js/inlines.js | 2 +- django/contrib/admin/static/admin/js/inlines.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/static/admin/js/inlines.js b/django/contrib/admin/static/admin/js/inlines.js index 668e1157c8..c11af82f76 100644 --- a/django/contrib/admin/static/admin/js/inlines.js +++ b/django/contrib/admin/static/admin/js/inlines.js @@ -44,7 +44,7 @@ if ($(this).attr("tagName") == "TR") { // If forms are laid out as table rows, insert the // "add" button in a new table row: - var numCols = this.eq(0).children().length; + var numCols = this.eq(-1).children().length; $(this).parent().append('' + options.addText + ""); addButton = $(this).parent().find("tr:last a"); } else { diff --git a/django/contrib/admin/static/admin/js/inlines.min.js b/django/contrib/admin/static/admin/js/inlines.min.js index 53dd92f2f9..e4a675407e 100644 --- a/django/contrib/admin/static/admin/js/inlines.min.js +++ b/django/contrib/admin/static/admin/js/inlines.min.js @@ -1,5 +1,5 @@ (function(b){b.fn.formset=function(c){var a=b.extend({},b.fn.formset.defaults,c),j=function(a,f,d){var e=RegExp("("+f+"-(\\d+|__prefix__))"),f=f+"-"+d;b(a).attr("for")&&b(a).attr("for",b(a).attr("for").replace(e,f));a.id&&(a.id=a.id.replace(e,f));a.name&&(a.name=a.name.replace(e,f))},c=b("#id_"+a.prefix+"-TOTAL_FORMS").attr("autocomplete","off"),h=parseInt(c.val(),10),g=b("#id_"+a.prefix+"-MAX_NUM_FORMS").attr("autocomplete","off"),c=""===g.val()||0'+a.addText+""),i=b(this).parent().find("tr:last a")):(b(this).filter(":last").after('"),i=b(this).filter(":last").next().find("a"));i.click(function(c){c.preventDefault(); +a.emptyCssClass).addClass(a.formCssClass)});if(b(this).length&&c){var i;"TR"==b(this).attr("tagName")?(c=this.eq(-1).children().length,b(this).parent().append(''+a.addText+""),i=b(this).parent().find("tr:last a")):(b(this).filter(":last").after('"),i=b(this).filter(":last").next().find("a"));i.click(function(c){c.preventDefault(); var f=b("#id_"+a.prefix+"-TOTAL_FORMS"),c=b("#"+a.prefix+"-empty"),d=c.clone(true);d.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+h);d.is("tr")?d.children(":last").append('
'+a.deleteText+"
"):d.is("ul")||d.is("ol")?d.append('
  • '+a.deleteText+"
  • "):d.children(":first").append(''+ a.deleteText+"");d.find("*").each(function(){j(this,a.prefix,f.val())});d.insertBefore(b(c));b(f).val(parseInt(f.val(),10)+1);h=h+1;g.val()!==""&&g.val()-f.val()<=0&&i.parent().hide();d.find("a."+a.deleteCssClass).click(function(e){e.preventDefault();e=b(this).parents("."+a.formCssClass);e.remove();h=h-1;a.removed&&a.removed(e);e=b("."+a.formCssClass);b("#id_"+a.prefix+"-TOTAL_FORMS").val(e.length);(g.val()===""||g.val()-e.length>0)&&i.parent().show();for(var c=0,d=e.length;c