mirror of
https://github.com/django/django.git
synced 2024-11-21 19:09:18 +01:00
Fixed #35599 -- Added ColorInput widget.
This commit is contained in:
parent
54e8b4e582
commit
946c3cf734
1
AUTHORS
1
AUTHORS
@ -112,6 +112,7 @@ answer newbie questions, and generally made Django that much better:
|
||||
Anže Pečar <anze@pecar.me>
|
||||
Aram Dulyan
|
||||
arien <regexbot@gmail.com>
|
||||
Arjun Omray <arjunomray@gmail.com>
|
||||
Armin Ronacher
|
||||
Aron Podrigal <aronp@guaranteedplus.com>
|
||||
Arsalan Ghassemi <arsalan.ghassemi@gmail.com>
|
||||
|
1
django/forms/jinja2/django/forms/widgets/color.html
Normal file
1
django/forms/jinja2/django/forms/widgets/color.html
Normal file
@ -0,0 +1 @@
|
||||
{% include "django/forms/widgets/input.html" %}
|
1
django/forms/templates/django/forms/widgets/color.html
Normal file
1
django/forms/templates/django/forms/widgets/color.html
Normal file
@ -0,0 +1 @@
|
||||
{% include "django/forms/widgets/input.html" %}
|
@ -30,6 +30,7 @@ __all__ = (
|
||||
"NumberInput",
|
||||
"EmailInput",
|
||||
"URLInput",
|
||||
"ColorInput",
|
||||
"SearchInput",
|
||||
"PasswordInput",
|
||||
"HiddenInput",
|
||||
@ -354,6 +355,11 @@ class URLInput(Input):
|
||||
template_name = "django/forms/widgets/url.html"
|
||||
|
||||
|
||||
class ColorInput(Input):
|
||||
input_type = "color"
|
||||
template_name = "django/forms/widgets/color.html"
|
||||
|
||||
|
||||
class SearchInput(Input):
|
||||
input_type = "search"
|
||||
template_name = "django/forms/widgets/search.html"
|
||||
|
@ -558,6 +558,17 @@ These widgets make use of the HTML elements ``input`` and ``textarea``.
|
||||
* ``template_name``: ``'django/forms/widgets/url.html'``
|
||||
* Renders as: ``<input type="url" ...>``
|
||||
|
||||
``ColorInput``
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
.. versionadded:: 5.2
|
||||
|
||||
.. class:: ColorInput
|
||||
|
||||
* ``input_type``: ``'color'``
|
||||
* ``template_name``:``'django/forms/widgets/color.html'``
|
||||
* Renders as: ``<input type='color' ...>``
|
||||
|
||||
``SearchInput``
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -166,6 +166,10 @@ File Uploads
|
||||
Forms
|
||||
~~~~~
|
||||
|
||||
* The new :class:`~django.forms.ColorInput` form widget is for entering a color
|
||||
in ``rrggbb`` hexadecimal format and renders as ``<input type='color' ...>``.
|
||||
Some browsers support a visual color picker interface for this input type.
|
||||
|
||||
* The new :class:`~django.forms.SearchInput` form widget is for entering search
|
||||
queries and renders as ``<input type="search" ...>``.
|
||||
|
||||
|
15
tests/forms_tests/widget_tests/test_colorinput.py
Normal file
15
tests/forms_tests/widget_tests/test_colorinput.py
Normal file
@ -0,0 +1,15 @@
|
||||
from django.forms import ColorInput
|
||||
|
||||
from .base import WidgetTest
|
||||
|
||||
|
||||
class ColorInputTest(WidgetTest):
|
||||
widget = ColorInput()
|
||||
|
||||
def test_render(self):
|
||||
self.check_html(
|
||||
self.widget,
|
||||
"color",
|
||||
"",
|
||||
html="<input type='color' name='color'>",
|
||||
)
|
Loading…
Reference in New Issue
Block a user