Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#12508 closed (fixed)

Feature: Dynamically adding inlines

Reported by: zain Owned by: jezdez
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: UI/UX:

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 5 years ago.
Fixed a bug related to spaces in verbose_name
inlines_patch.diff (809 bytes) - added by andraz 5 years ago.
hope this time the patch gets uploaded
field_numbering_off_by_one.diff (4.1 KB) - added by stefanfoulis 5 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 stefanfoulis 5 years ago.
Fixes faulty field numbering for ForeigKeys (add link and field. and potentially others)

Download all attachments as: .zip

Change History (9)

Changed 5 years ago by zain

Fixed a bug related to spaces in verbose_name

comment:1 Changed 5 years ago by jezdez

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from zain to jezdez
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 5 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

(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 Changed 5 years ago by andraz

  • Resolution fixed deleted
  • Status changed from closed to reopened

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:

Changed 5 years ago by andraz

hope this time the patch gets uploaded

comment:4 Changed 5 years ago by Alex

  • Resolution set to fixed
  • Status changed from reopened to closed

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

Changed 5 years ago by stefanfoulis

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

Changed 5 years ago by stefanfoulis

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

comment:5 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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