#13674: Javascript for adding inline fields doesn't update "for" attribute in label ---------------------------+------------------------------------------------ Reporter: Jonas | Owner: nobody Status: new | Milestone: Component: Uncategorized | Version: 1.2 Keywords: admin | Stage: Unreviewed Has_patch: 1 | ---------------------------+------------------------------------------------ I do some checking for required fields using Javascript in the admin. Doing that, I noticed that adding inline fields doesn't update the "for" attribute for the new <label> fields. If the field is called "image", the newly added field label looks like this:
{{{ <label class="required" for="id_images-__prefix__-image">Image:</label> }}} This is the patch that solved it for me: {{{ diff --git a/django/contrib/admin/media/js/inlines.js b/django/contrib/admin/media/js/inlines.js index cf79023..90b50b5 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 }}} -- Ticket URL: <http://code.djangoproject.com/ticket/13674> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.