Commits

James Crasta  committed ac1a4ea Merge

Merged in dplepage/wtforms (pull request #18)

Add html5 input classes.

  • Participants
  • Parent commits 8b2a026, 30ba086

Comments (0)

Files changed (2)

File wtforms/fields/html5.py

+import wtforms.widgets.html5 as widgets
+
+import core
+
+
+class SearchField(core.StringField):
+    """
+    Represents an ``<input type="search">``.
+    """
+    widget = widgets.SearchInput()
+
+
+class TelField(core.StringField):
+    """
+    Represents an ``<input type="tel">``.
+    """
+    widget = widgets.TelInput()
+
+
+class URLField(core.StringField):
+    """
+    Represents an ``<input type="url">``.
+    """
+    widget = widgets.URLInput()
+
+
+class EmailField(core.StringField):
+    """
+    Represents an ``<input type="email">``.
+    """
+    widget = widgets.EmailInput()
+
+
+class DateTimeField(core.DateTimeField):
+    """
+    Represents an ``<input type="datetime">``.
+    """
+    widget = widgets.DateTimeInput()
+
+
+class DateField(core.DateField):
+    """
+    Represents an ``<input type="date">``.
+    """
+    widget = widgets.DateInput()
+
+
+class DateTimeLocalField(core.DateTimeField):
+    """
+    Represents an ``<input type="datetime-local">``.
+    """
+    widget = widgets.DateTimeLocalInput()
+
+
+class IntegerField(core.IntegerField):
+    """
+    Represents an ``<input type="number">``.
+    """
+    widget = widgets.NumberInput()
+
+
+class DecimalField(core.DecimalField):
+    """
+    Represents an ``<input type="number">``.
+    """
+    widget = widgets.NumberInput()
+
+
+class IntegerRangeField(core.IntegerField):
+    """
+    Represents an ``<input type="range">``.
+    """
+    widget = widgets.RangeInput()
+
+
+class DecimalRangeField(core.DecimalField):
+    """
+    Represents an ``<input type="range">``.
+    """
+    widget = widgets.RangeInput()
+

File wtforms/widgets/html5.py

+"""
+Widgets for various HTML5 input types.
+"""
+
+from .core import Input
+
+
+class SearchInput(Input):
+    """
+    Renders an input with type "search".
+    """
+    input_type = "search"
+
+
+class TelInput(Input):
+    """
+    Renders an input with type "tel".
+    """
+    input_type = "tel"
+
+
+class URLInput(Input):
+    """
+    Renders an input with type "url".
+    """
+    input_type = "url"
+
+
+class EmailInput(Input):
+    """
+    Renders an input with type "email".
+    """
+    input_type = "email"
+
+
+class DateTimeInput(Input):
+    """
+    Renders an input with type "datetime".
+    """
+    input_type = "datetime"
+
+
+class DateInput(Input):
+    """
+    Renders an input with type "date".
+    """
+    input_type = "date"
+
+
+class MonthInput(Input):
+    """
+    Renders an input with type "month".
+    """
+    input_type = "month"
+
+
+class WeekInput(Input):
+    """
+    Renders an input with type "week".
+    """
+    input_type = "week"
+
+
+class TimeInput(Input):
+    """
+    Renders an input with type "time".
+    """
+    input_type = "time"
+
+
+class DateTimeLocalInput(Input):
+    """
+    Renders an input with type "datetime-local".
+    """
+    input_type = "datetime-local"
+
+
+class NumberInput(Input):
+    """
+    Renders an input with type "number".
+    """
+    input_type = "number"
+
+
+class RangeInput(Input):
+    """
+    Renders an input with type "range".
+    """
+    input_type = "range"
+
+
+class ColorInput(Input):
+    """
+    Renders an input with type "color".
+    """
+    input_type = "color"