Commits

Anonymous committed 8417bce

[soc2009/admin-ui] Fix for ticket #11718: "When there is an error in a SelectorInline, there is no way to tell which inline has the error"

The selector with the error is now highlighted and selected on reload.

Comments (0)

Files changed (2)

django/contrib/admin/media/css/forms.css

     background-color: #C1DBFD;
 }
 
+.selector-error {
+    font-weight: bold;
+    border: 2px solid #F00000 !important;
+}
+
+
 .inline-detail {
     float: right;
     width: 80%;

django/contrib/admin/templates/admin/edit_inline/selector.html

 <script type="text/javascript">
 $(function() {
     /* Selector */
+    function select_inline(inline) {
+        $('.inline-detail .selector-item-detail').hide();
+        $('.inline-selector .inline-selector-item').removeClass('inline-selected');
+
+        $(inline).addClass('inline-selected');
+        
+        var div_to_show = '#' + $(inline).find('a').attr('title');
+        $(div_to_show).show();
+    }
+    
     $('.inline-detail .selector-item-detail').hide();
     $('.inline-detail .selector-item-detail:first').show();
     $('.inline-selector .inline-selector-item:first').addClass('inline-selected');
+    $('.form-row.errors').each(function() {
+        var id = $(this).parents('.selector-item-detail').attr('id').substring({{ inline_admin_formset.opts.verbose_name|length}});
+        $("#{{ inline_admin_formset.opts.verbose_name}}" + id + "-selector").addClass('selector-error');
+    });
+    
+    if ($('.form-row.errors').html()) {
+        select_inline('.selector-error:first');
+    }
+    else {
+        select_inline('.inline-selector-item:first');
+    }
     
     $('.inline-selector-item').click(function () {
-        $('.inline-detail .selector-item-detail').hide();
-        $('.inline-selector .inline-selector-item').removeClass('inline-selected');
-
-        $(this).addClass('inline-selected');
-        
-        var div_to_show = '#' + $(this).find('a').attr('title');
-        $(div_to_show).show();
-        
+        select_inline(this);
         return false;
     });