Projet

Général

Profil

Development #74541

Filtre |with_template, field.id_for_label peut être vide

Ajouté par Valentin Deniaud il y a environ un an. Mis à jour il y a environ un an.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
-
Début:
15 février 2023
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

Description

Dans le code de Django on a pour CheckboxSelectMultiple :

    def id_for_label(self, id_, index=None):
        """ 
        Don't include for="field_0" in <label> because clicking such a label
        would toggle the first checkbox.
        """ 
        if index is None:
            return ''
        return super().id_for_label(id_, index)

Et dans la mécanique de rendu form.as_p(), qui donne normalement des <label for="...", ce bout

            id_for_label = widget.id_for_label(id_)
            if id_for_label:
                attrs = {**(attrs or {}), 'for': id_for_label}

Qui peut se résumer par « ne pas inclure d'attribut for= vide ».

Cette vérif a été oubliée dans gadjo qui fait id="{{field.id_for_label}}_p", et donc dans le cas d'un widget CheckboxSelectMultiple, on se retrouve avec id="_p" ce qui est nul.


Fichiers

Révisions associées

Révision bbcd1746 (diff)
Ajouté par Valentin Deniaud il y a environ un an

templates: avoid empty id attribute in widget (#74541)

Historique

#1

Mis à jour par Valentin Deniaud il y a environ un an

Bon je me suis bien foiré, jamais codé dans gadjo depuis gitea et sur ma branche wip/ en local j'ai tapé git remote add gitea gitea@gitea.entrouvert.org:entrouvert/gadjo.git && git push gitea ce qui a poussé sur main...

Mon patch me paraît plutôt simple donc je revert pas sauf contre ordre, voici pour validation à posteriori.

#2

Mis à jour par Valentin Deniaud il y a environ un an

Valentin Deniaud a écrit :

Bon je me suis bien foiré, jamais codé dans gadjo depuis gitea et sur ma branche wip/ en local j'ai tapé git remote add gitea gitea@gitea.entrouvert.org:entrouvert/gadjo.git && git push gitea ce qui a poussé sur main...

Rien à voir en fait gadjo n'a pas été migré, mon git push gitea a créé un dépôt, wtf. Pas de problème sur main en tout cas, tant mieux.

#3

Mis à jour par Frédéric Péters il y a environ un an

  • Statut changé de Solution proposée à Solution validée

C'est ok (tape le patch en PR si tu veux).

#4

Mis à jour par Valentin Deniaud il y a environ un an

  • Statut changé de Solution validée à Résolu (à déployer)
commit bbcd17465facdff14da1104de44476ff33c31973
Author: Valentin Deniaud <vdeniaud@entrouvert.com>
Date:   Wed Feb 15 11:53:11 2023 +0100

    templates: avoid empty id attribute in widget (#74541)
#5

Mis à jour par Transition automatique il y a environ un an

  • Statut changé de Résolu (à déployer) à Solution déployée
#6

Mis à jour par Transition automatique il y a environ un an

Automatic expiration

Formats disponibles : Atom PDF