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?
--
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 django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
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.
Hi,If it helps It looks like there's a widget.input_type attribute, so you can at least do {% if theform.thefield.field.widget.input_type == "checkbox" %} etc.Collin
On Mon, Mar 20, 2017 at 9:46 AM, Paweł Adamczak <pawe...@gmail.com> wrote:
Hiya,I would like to 'resurrect' 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.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 based on the HTML spec, 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 django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.