﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18242	Making widget type accessible in template	Selwin Ong	nobody	"Hi there,

Is there a possibility to add a `type` attribute to form widgets? The goal is to make it easy for designers to apply different styles to each widget type while keeping the template code DRY.


Django's current source code already does something similar for ""<input>"" based widgets such as `TextInput` and `DateInput` (though for a different purpose). These widgets have `input_type` attribute attached to them so we can already do:
{{{
<ul>
{% for field in form %}
    <li class = '{{ field.field.widget.input_type }}'>
        {{ field }}
    </li>
{% endfor %}
</ul>
}}}


But the above means we can only target `input` based widgets and not `select`, `textarea` etc. If we add a more generic `type` (e.g ""select"", ""checkbox"", ""textarea"") attribute to widgets, we'll be able to do:

{{{
<ul>
{% for field in form %}
    <li class = '{{ field.field.widget.type }}'>
        {{ field }}
    </li>
{% endfor %}
</ul>
}}}

Or even better (if we attach widgets to `BoundField`):

{{{
<ul>
{% for field in form %}
    <li class = '{{ field.widget.type }}'>
        {{ field }}
    </li>
{% endfor %}
</ul>
}}}

If it sounds like a good idea, I'd be more than willing to try writing a patch for this."	New feature	closed	Forms	1.3	Normal	wontfix		Selwin Ong	Design decision needed	0	0	0	0	0	0
