#32125: Added basic support for <datalist> elements for suggestions in Input
widgets
-------------------------------------+-------------------------------------
     Reporter:  Volodymyr            |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Forms                |                  Version:  dev
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  datalist, forms,     |             Triage Stage:
  html5                              |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  1
-------------------------------------+-------------------------------------

Comment (by christophertubbs):

 This recently popped up as a need in one of our products. Having the extra
 option on the `TextInput` widget or something and copying some of the
 select widget logic would probably make things pretty simple. Something
 like:


 **django/forms/templates/django/forms/widgets/text.html:**
 {{{
 {% include "django/forms/widgets/input.html" %}
 {% if widget.datalist %}
 <datalist id="{{ widget.name }}__datalist">
     {% for group_name, group_choices, group_index in widget.datalist %}
         {% if group_name %}
             <optgroup label="{{ group_name }}">
         {% endif %}
         {% for option in group_choices %}
             {% include option.template_name with widget=option %}
         {% endfor %}
         {% if group_name %}
             </optgroup>
         {% endif %}
     {% endfor %}
 </datalist>
 {% endif %}
 }}}

 It's nothing too terribly fancy. You'd need to make sure that the widget
 has {{{ {"list": name + "__datalist"} }}} is in the attributes to make
 sure that that datalist has the right name for the linkage.

 You can always go fancier or more robust with it, but something fairly
 simple that can be tacked onto the standard text widget would be awesome.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32125#comment:4>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/01070187d9233976-07cb0069-98ae-4c5c-91c7-4345e017d508-000000%40eu-central-1.amazonses.com.

Reply via email to