Permalink
Browse files

Fixed #13175 - Fixed an off-by-one error in the admin inline JavaScri…

…pt that resulted in wrong form field prefixes. Thanks DrMeers for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12871 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent dae7d0b commit 9df8d9c2946bf74288d410e2dc8917493b079b11 @jezdez jezdez committed Mar 27, 2010
Showing with 7 additions and 7 deletions.
  1. +3 −3 django/contrib/admin/media/js/inlines.js
  2. +4 −4 django/contrib/admin/media/js/inlines.min.js
@@ -52,12 +52,12 @@
}
addButton.click(function() {
var totalForms = $("#id_" + options.prefix + "-TOTAL_FORMS");
- var nextIndex = parseInt(totalForms.val()) + 1;
+ var nextIndex = parseInt(totalForms.val());
var template = $("#" + options.prefix + "-empty");
var row = template.clone(true).get(0);
$(row).removeClass(options.emptyCssClass).removeAttr("id").insertBefore($(template));
$(row).html($(row).html().replace(/__prefix__/g, nextIndex));
- $(row).addClass(options.formCssClass).attr("id", options.prefix + nextIndex);
+ $(row).addClass(options.formCssClass).attr("id", options.prefix + (nextIndex + 1));
if ($(row).is("TR")) {
// If the forms are laid out in table rows, insert
// the remove button into the last table cell:
@@ -75,7 +75,7 @@
updateElementIndex(this, options.prefix, totalForms.val());
});
// Update number of total forms
- $(totalForms).val(nextIndex);
+ $(totalForms).val(nextIndex + 1);
// Hide add button in case we've hit the max, except we want to add infinitely
if ((maxForms.val() != 0) && (maxForms.val() <= totalForms.val())) {
addButton.parent().hide();

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 9df8d9c

Please sign in to comment.