#30306: Textarea widget missing input_type
-------------------------------------+-------------------------------------
     Reporter:  minusf               |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Forms                |                  Version:  2.2
     Severity:  Normal               |               Resolution:  invalid
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Scott Cranfill):

 I just ran into this working in a template where I was checking
 `input_type` in order to fully customize the markup for the field. Here's
 a simplified example:

 {{{
 {% with field_type=field.field.widget.input_type %}
     {% if field_type == "text" or field_type == "email" %}
         <input type="{{ field_type }}">
     {% elif field_type == "select" %}
         <select>...</select>
     {% endif %}
 {% endwith %}
 }}}

 I was quite surprised when I went to add `{% elif field_type == "textarea"
 %}` and it had no effect.

 There may be a better way to handle it, but for now I'm checking
 `field.field.widget.template_name ==
 "django/forms/widgets/textarea.html"`.

 It would be nice if this could be reconsidered. It's a one-line addition
 that would seem to me to make things more consistent and predictable. I
 would be happy to submit a PR if this is reopened.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/30306#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019df982b3d2-01fa6ccd-6284-4e38-976c-b27715785c1d-000000%40eu-central-1.amazonses.com.

Reply via email to