Opened 3 weeks ago

Closed 3 weeks ago

#35721 closed Bug (invalid)

widget template attrs.html needs space for attrs with True value

Reported by: Yingjie Lan Owned by:
Component: Forms Version: 5.0
Severity: Normal Keywords: widget attrs template
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

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 %}

Change History (1)

comment:1 by Yingjie Lan, 3 weeks ago

Resolution: invalid
Status: newclosed

Sorry, my copy of the attrs.html template was probably modified inadvertently. The original version is correct.

Note: See TracTickets for help on using tickets.
Back to Top