Skip to content

Used slugify template tag for tabs not working with non-ASCII alphanumeric characters #237

@EngFarisAlsmawi

Description

@EngFarisAlsmawi

Hello,
Thank you for your amazing django package

When used slugify template tag for tabs not working with non-ASCII alphanumeric characters

<button type="button" id="tablink-{{ tab_name|slugify }}" class="tabbed-changeform-tablink {{ forloop.counter0|default:'active' }}" onclick="AdminInterface.tabbedChangeForm.openTab(event, '{{ tab_name|slugify }}')">

instated you can used forloop counter

used tab with loop of counter for fieldset

<button type="button" id="tablink-tab{{  forloop.counter   }}" class="tabbed-changeform-tablink {{ forloop.counter0|default:'active' }}" onclick="AdminInterface.tabbedChangeForm.openTab(event, 'tab{{forloop.counter }}')">
                    {{ tab_name|capfirst }}
                </button>

Used** tab0 for fieldsets without tabs

used itab with loop counter for inlines formset

<button type="button" id="tablink-itab{{ forloop.counter }}" class="tabbed-changeform-tablink" onclick="AdminInterface.tabbedChangeForm.openTab(event, 'itab{{ forloop.counter }}')">
                    {{ tab_name|capfirst }}
                </button>

this is full patch code:

  <div id="tabbed-changeform-tabs" class="tabbed-changeform-tabs">

            {% if show_fieldsets_as_tabs %}
                {% for fieldset in adminform %}

                {% with fieldset.name|default_if_none:opts.verbose_name as tab_name %}
                <button type="button" id="tablink-tab{{  forloop.counter   }}" class="tabbed-changeform-tablink {{ forloop.counter0|default:'active' }}" onclick="AdminInterface.tabbedChangeForm.openTab(event, 'tab{{forloop.counter }}')">
                    {{ tab_name|capfirst }}
                </button>
                {% endwith %}

                {% endfor %}
            {% else %}
                {% with opts.verbose_name as tab_name %}
                <button type="button" id="tablink-tab0" class="tabbed-changeform-tablink active" onclick="AdminInterface.tabbedChangeForm.openTab(event, 'tab0')">
                    {{ tab_name|capfirst }}
                </button>
                {% endwith %}
            {% endif %}

            {% if show_inlines_as_tabs %}
                {% for inline_admin_formset in inline_admin_formsets %}
                {% with inline_admin_formset.opts.verbose_name_plural as tab_name %}
                <button type="button" id="tablink-itab{{ forloop.counter }}" class="tabbed-changeform-tablink" onclick="AdminInterface.tabbedChangeForm.openTab(event, 'itab{{ forloop.counter }}')">
                    {{ tab_name|capfirst }}
                </button>
                {% endwith %}
                {% endfor %}
            {% endif %}

            <span class="tabbed-changeform-tabs-remaining-space"></span>

        </div>

        {% if show_fieldsets_as_tabs %}
            {% for fieldset in adminform %}
            {% with fieldset.name|default_if_none:opts.verbose_name as tab_name %}
            <div id="tabcontent-tab{{ forloop.counter }}" class="tabbed-changeform-tabcontent {{ forloop.counter0|default:'active' }}">
                {% include "admin/includes/headerless_fieldset.html" %}
            </div>
            {% endwith %}
            {% endfor %}
        {% else %}
            {% with opts.verbose_name as tab_name %}
            <div id="tabcontent-tab0" class="tabbed-changeform-tabcontent active">
            {% for fieldset in adminform %}
                {% include "admin/includes/fieldset.html" %}
            {% endfor %}
            </div>
            {% endwith %}
        {% endif %}

        {% for inline_admin_formset in inline_admin_formsets  %}
        {% with inline_admin_formset.opts.verbose_name_plural as tab_name %}
        <div id="tabcontent-itab{{ forloop.counter }}" class="tabbed-changeform-tabcontent">
            {% get_admin_interface_inline_template inline_admin_formset.opts.template as inline_template %}
            {% include inline_template %}
        </div>
        {% endwith %}
        {% endfor %}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions