[Django] #35721: widget template attrs.html needs space for attrs with True value

5 views
Skip to first unread message

Django

unread,
Aug 30, 2024, 4:15:54 AM8/30/24
to django-...@googlegroups.com
#35721: widget template attrs.html needs space for attrs with True value
-------------------------------------+-------------------------------------
Reporter: Yingjie Lan | Type: Bug
Status: new | Component: Forms
Version: 5.0 | Severity: Normal
Keywords: widget attrs | Triage Stage:
template | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
If you have a hidden input widget w with w.attrs being {'disabled':True,
'id':'myinput'}, you will get this:

{{{
<input type="hidden" name="myfield"disabledid="myinput">
}}}

The desired output should be:

{{{
<input type="hidden" name="myfield" disabled id="myinput">
}}}

To fix this, the template file attrs.html needs to add a space before {{
name }} as follows:

{{{
{% for name, value in widget.attrs.items %}{% if value is not False %} {{
name }}{% if value is not True %}="{{ value|stringformat:'s' }}"{% endif
%}{% endif %}{% endfor %}
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35721>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 30, 2024, 4:31:02 AM8/30/24
to django-...@googlegroups.com
#35721: widget template attrs.html needs space for attrs with True value
-------------------------------------+-------------------------------------
Reporter: Yingjie Lan | Owner: (none)
Type: Bug | Status: closed
Component: Forms | Version: 5.0
Severity: Normal | Resolution: invalid
Keywords: widget attrs | Triage Stage:
template | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Yingjie Lan):

* resolution: => invalid
* status: new => closed

Comment:

Sorry, my copy of the attrs.html template was probably modified
inadvertently. The original version is correct.
--
Ticket URL: <https://code.djangoproject.com/ticket/35721#comment:1>
Reply all
Reply to author
Forward
0 new messages