#14830: Default value for radio button not preserved when dynamically creating new inlines -------------------------------------------+-------------------------------- Reporter: julien | Owner: nobody Status: new | Milestone: 1.3 Component: django.contrib.admin | Version: 1.2 Resolution: | Keywords: sprintdec2010 Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | -------------------------------------------+-------------------------------- Comment (by antoinemartin):
The issue comes from the fact that when the row is inserted, the radio elements have the name as in the template. As only one radio element with the same name can be checked, the browser "unchecks" the radio in the template. To fix this, simply move the addition of the new form in the document DOM after having changed the names and ids in the template: {{{ row.removeClass(options.emptyCssClass) .addClass(options.formCssClass) .attr("id", options.prefix + "-" + nextIndex) // Remove insertion from here // .insertBefore($(template)); }}} ... {{{ row.find("input,select,textarea,label,a").each(function() { updateElementIndex(this, options.prefix, totalForms.val()); }); // Insert the new form when it has been fully edited row.insertBefore($(template)); // Update number of total forms $(totalForms).val(nextIndex + 1); }}} -- Ticket URL: <http://code.djangoproject.com/ticket/14830#comment:3> 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.