Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#12508 closed (fixed)

Feature: Dynamically adding inlines

Reported by: Zain Memon Owned by: Jannis Leidel
Component: contrib.admin Version: soc2009/admin-ui
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This patch adds the ability to add extra inlines dynamically with a "Add new <model>" link at the bottom of the inline. When Javascript is enabled, extra forms for inlines are hidden on load and the "add new <model>" link is unhidden.

Attachments (4)

adminui-newinlines.diff (72.1 KB ) - added by Zain Memon 14 years ago.
Fixed a bug related to spaces in verbose_name
inlines_patch.diff (809 bytes ) - added by andraz 14 years ago.
hope this time the patch gets uploaded
field_numbering_off_by_one.diff (4.1 KB ) - added by Stefan Foulis 14 years ago.
Fixes faulty field numbering for ForeigKeys (add link and field. and potentially others)
field_numbering_off_by_one.2.diff (3.9 KB ) - added by Stefan Foulis 14 years ago.
Fixes faulty field numbering for ForeigKeys (add link and field. and potentially others)

Download all attachments as: .zip

Change History (9)

by Zain Memon, 14 years ago

Attachment: adminui-newinlines.diff added

Fixed a bug related to spaces in verbose_name

comment:1 by Jannis Leidel, 14 years ago

Owner: changed from Zain Memon to Jannis Leidel
Triage Stage: UnreviewedAccepted

FYI, my current status can be found here: http://github.com/jezdez/django/tree/admin-ui-combined

("combined" with the select-across feature of #12282 which I've ported to jQuery, as well)

comment:2 by Jannis Leidel, 14 years ago

Resolution: fixed
Status: newclosed

(In [12297]) Fixed #12508 - Added ability to dynamically add inlines in the admin app.

Refs #13. Also introduces an empty_form attribute on formsets to make it easier to implement dynamic forms.

Many thanks to Zain Memon for the initial patch from his Summer of Code 2009 project, Stanislaus Madueke for his django-dynamic-formset app and all the other people helping out.

comment:3 by andraz, 14 years ago

Resolution: fixed
Status: closedreopened

there's a bug with current implementation, when using ManyToManyField and raw_id_admin, the ids of the fields are off-by-one and thus when popup closes the value is entered in a row after the one that the user clicked on to change.

Since ticketing system thinks my patch is a spam, here's a simple patch to make it work:

--- inlines.js (revision 12486)
+++ inlines.js (working copy)
@@ -56,8 +56,8 @@

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).html($(row).html().replace(/prefix/g, totalForms.val()));
+ $(row).addClass(options.formCssClass).attr("id", options.prefix + totalForms.val());

if ($(row).is("TR")) {

If the forms are laid out in table rows, insert
the remove button into the last table cell:

by andraz, 14 years ago

Attachment: inlines_patch.diff added

hope this time the patch gets uploaded

comment:4 by Alex Gaynor, 14 years ago

Resolution: fixed
Status: reopenedclosed

This was fixed, if there's a new bug please file it.

by Stefan Foulis, 14 years ago

Fixes faulty field numbering for ForeigKeys (add link and field. and potentially others)

by Stefan Foulis, 14 years ago

Fixes faulty field numbering for ForeigKeys (add link and field. and potentially others)

comment:5 by Jacob, 12 years ago

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top