#11277: Hidden fields in Inlines are displayed as empty rows
-------------------------------------+-------------------------------------
               Reporter:  bartTC     |          Owner:  nobody
                   Type:  Bug        |         Status:  reopened
              Milestone:             |      Component:  contrib.admin
                Version:  SVN        |       Severity:  Normal
             Resolution:             |       Keywords:  admin inlines
           Triage Stage:  Accepted   |  hiddeninput
    Needs documentation:  0          |      Has patch:  1
Patch needs improvement:  1          |    Needs tests:  1
                  UI/UX:  1          |  Easy pickings:  0
-------------------------------------+-------------------------------------
Changes (by julien):

 * needs_better_patch:  0 => 1
 * ui_ux:  0 => 1
 * easy:  1 => 0
 * needs_tests:  0 => 1


Comment:

 The patch needs tests. It also needs to cater for when the `Fieldline`
 contains only one, hidden, field (in which case the entire row, including
 the label and help_text, show be hidden -- see #7859 and #14372), or when
 it contains a mix of hidden and non-hidden fields (in which case the row
 should be displayed and the non-hidden fields should also be displayed
 correctly).

 By the way, I could reproduce the issue with the following code:

 {{{#!python
 # models.py

 from django.db import models
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic

 class Restaurant(models.Model):
     name = models.CharField(max_length=200)

 class Location(models.Model):
     content_type = models.ForeignKey(ContentType)
     object_id = models.PositiveIntegerField()
     content_object = generic.GenericForeignKey('content_type',
 'object_id')
     longitude = models.FloatField(blank=True)
     latitude = models.FloatField(blank=True)

 # admin.py

 from django.contrib import admin
 from django import forms
 from django.contrib.contenttypes.generic import GenericStackedInline

 from .models import Restaurant, Location

 class LocationForm(forms.ModelForm):
     latitude = forms.FloatField(widget=forms.HiddenInput)
     longitude = forms.FloatField(widget=forms.HiddenInput)

 class LocationInline(GenericStackedInline):
     model = Location
     form = LocationForm
     extra = 1
     max_num = 1

 class RestaurantAdmin(admin.ModelAdmin):
     inlines = [LocationInline]

 admin.site.register(Restaurant, RestaurantAdmin)

 }}}

 This is however not tied to generic inlines in particular, but is relevant
 to any form of any kind (main forms, regular inline forms and generic
 inline forms).

-- 
Ticket URL: <https://code.djangoproject.com/ticket/11277#comment:12>
Django <https://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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to