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 DateTimeInput(Input):
"""
Renders an input with type "datetime".
"""
input_type = 'datetime'
[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)