Source code for wtforms.widgets.html5

"""
Widgets for various HTML5 input types.
"""

from .core import Input

__all__ = (
    'ColorInput', 'DateInput', 'DateTimeInput', 'DateTimeLocalInput',
    'EmailInput', 'MonthInput', 'NumberInput', 'RangeInput', 'SearchInput',
    'TelInput', 'TimeInput', 'URLInput', 'WeekInput',
)


[docs]class SearchInput(Input): """ Renders an input with type "search". """ input_type = 'search'
[docs]class TelInput(Input): """ Renders an input with type "tel". """ input_type = 'tel'
[docs]class URLInput(Input): """ Renders an input with type "url". """ input_type = 'url'
[docs]class EmailInput(Input): """ Renders an input with type "email". """ input_type = 'email'
[docs]class DateTimeInput(Input): """ Renders an input with type "datetime". """ input_type = 'datetime'
[docs]class DateInput(Input): """ Renders an input with type "date". """ input_type = 'date'
[docs]class MonthInput(Input): """ Renders an input with type "month". """ input_type = 'month'
[docs]class WeekInput(Input): """ Renders an input with type "week". """ input_type = 'week'
[docs]class TimeInput(Input): """ Renders an input with type "time". """ input_type = 'time'
[docs]class DateTimeLocalInput(Input): """ Renders an input with type "datetime-local". """ input_type = 'datetime-local'
[docs]class NumberInput(Input): """ Renders an input with type "number". """ input_type = 'number' def __init__(self, step=None, min=None, max=None): self.step = step self.min = min self.max = max def __call__(self, field, **kwargs): if self.step is not None: kwargs.setdefault('step', self.step) if self.min is not None: kwargs.setdefault('min', self.min) if self.max is not None: kwargs.setdefault('max', self.max) return super(NumberInput, self).__call__(field, **kwargs)
[docs]class RangeInput(Input): """ Renders an input with type "range". """ input_type = 'range' def __init__(self, step=None): self.step = step def __call__(self, field, **kwargs): if self.step is not None: kwargs.setdefault('step', self.step) return super(RangeInput, self).__call__(field, **kwargs)
[docs]class ColorInput(Input): """ Renders an input with type "color". """ input_type = 'color'