omji / django-tabbed-admin

Easily add tabs to django admin forms
BSD 3-Clause "New" or "Revised" License
63 stars 68 forks source link

Admin `collapse` does not work like in the fieldsets #31

Closed iwalucas closed 5 years ago

iwalucas commented 5 years ago

In a django fieldset, if you define the collapse class, it would enable a hide/show functionality. But that doesnt happen with the tabs.

Here is the example of one of my tabs:

  tab_overview=(
        (None,{
            'fields':('end_dt','name',),
            }),  
        ('Extra',{'fields':('start_dt',),
          'classes': ['collapse']}),
        )  

The html does get the collapse:

<fieldset class="module aligned collapse">
    <h2>Extra</h2>

        <div class="form-row field-start_dt">

                <div>

                        <label class="required" for="id_start_dt">Start Date:</label>

                            <input type="text" name="start_dt" value="2018-09-09" class="vDateField" size="10" required="" id="id_start_dt"><span class="datetimeshortcuts">&nbsp;<a href="#">Today</a>&nbsp;|&nbsp;<a href="#" id="calendarlink0"><span class="date-icon" title="Choose a Date"></span></a></span>

                <br><span class="timezonewarning">Note: You are 3 hours behind server time.</span></div>

        </div>

</fieldset>

But it doesn have the hide/show functionality

iwalucas commented 5 years ago

Found out the problem, the collapse.js is not loading.... found a couple fixes:

add

    class Media:
        js = ('/static/admin/js/collapse.js',) 

or add a fieldsets with the same structure of the tab

iwalucas commented 5 years ago

turns out the problem was that I have double inheritance with tabbedadmin, so I changed the order of inheritance and it solved itself out