Hiya,

I would like to 'resurrect' ticket #13009 
<https://code.djangoproject.com/ticket/13009>, or at least discuss it.

I think that the suggested feature would be beneficial, as it comes up 
every time I'm implementing HTML flats different types of fields require 
different rendering (the most common example being checkboxes, where the 
input field is before the label). Adding an easy, builtin method of 
checking the field type/widget would be much nicer in my opinion then using 
then using  - just for example - this approach 
<http://stackoverflow.com/a/14291933/3023841>.

That question also comes up in couple of StackOverflow questions:
- 
http://stackoverflow.com/questions/3927018/django-how-to-check-if-field-widget-is-checkbox-in-the-template
 
(viewed 7594 times)
- 
http://stackoverflow.com/questions/1809874/get-type-of-django-form-widget-from-within-template
 
(viewed 15015 times)
- 
http://stackoverflow.com/questions/20424375/django-templates-how-to-know-form-field-type-and-add-any-buttons-based-on-field
 
(viewed 3633 times)

>From the ticket:

> Broadly the idea has merit, but it needs a bit of finesse - specifically, 
> what determines the "type" of the field? Do we just use the type of the 
> input element on the widget? What do we do in the case of multi-widgets?

 
As far as I understand Django tries to structure its widget structure  
<https://docs.djangoproject.com/en/1.10/ref/forms/widgets/#widgets-handling-input-of-text>based
 
on the HTML spec <https://www.w3schools.com/tags/att_input_type.asp>, and I 
would follow that convention as close as possible, with widget 'types' (the 
nomenclature would probably need to be different) like 'input_text', 
'input_email', ..., 'input_radio', 'input_checkbox', and 'select'. In other 
cases we would just mimic the widget name ('multi_widget'). 

What do you think?
I would be happy to contribute to Django and implement the above in a 
feature pull request.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/02725db5-3873-4651-9f2e-01c7b2af9f85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to