201 |
201 |
attrs['autocomplete'] = self.prefill_attributes['autocomplete']
|
202 |
202 |
if self.attrs:
|
203 |
203 |
attrs.update(self.attrs)
|
|
204 |
if getattr(self, 'inputmode', None):
|
|
205 |
attrs['inputmode'] = self.inputmode
|
204 |
206 |
return htmltag("input", xml_end=True, type=self.HTML_TYPE, name=self.name,
|
205 |
207 |
value=self.value, **attrs)
|
206 |
208 |
StringWidget.render_content = string_render_content
|
... | ... | |
951 |
953 |
class ValidationWidget(CompositeWidget):
|
952 |
954 |
validation_methods = collections.OrderedDict([
|
953 |
955 |
('digits', {'title': N_('Digits'), 'regex': '\d+'}),
|
954 |
|
('phone', {'title': N_('Phone Number'), 'regex': r'\+?[-\(\)\d\.\s/]+', 'html_input_type': 'tel'}),
|
955 |
|
('phone-fr', {'title': N_('Phone Number (France)'), 'function': 'validate_phone_fr', 'html_input_type': 'tel'}),
|
956 |
|
('zipcode-fr', {'title': N_('Zip Code (France)'), 'regex': '\d{5}'}),
|
957 |
|
('siren-fr', {'title': N_('SIREN Code (France)'), 'function': 'validate_siren'}),
|
958 |
|
('siret-fr', {'title': N_('SIRET Code (France)'), 'function': 'validate_siret'}),
|
959 |
|
('nir-fr', {'title': N_('NIR (France)'), 'function': 'validate_nir'}),
|
960 |
|
('iban', {'title': N_('IBAN'), 'function': 'validate_iban'}),
|
|
956 |
('phone', {
|
|
957 |
'title': N_('Phone Number'),
|
|
958 |
'regex': r'\+?[-\(\)\d\.\s/]+',
|
|
959 |
'html_input_type': 'tel'}
|
|
960 |
),
|
|
961 |
('phone-fr', {
|
|
962 |
'title': N_('Phone Number (France)'),
|
|
963 |
'function': 'validate_phone_fr',
|
|
964 |
'html_input_type': 'tel'}
|
|
965 |
),
|
|
966 |
('zipcode-fr', {
|
|
967 |
'title': N_('Zip Code (France)'),
|
|
968 |
'regex': r'\d{5}',
|
|
969 |
'html_inputmode': 'number'}
|
|
970 |
),
|
|
971 |
('siren-fr', {
|
|
972 |
'title': N_('SIREN Code (France)'),
|
|
973 |
'function': 'validate_siren',
|
|
974 |
'html_inputmode': 'number'}
|
|
975 |
),
|
|
976 |
('siret-fr', {
|
|
977 |
'title': N_('SIRET Code (France)'),
|
|
978 |
'function': 'validate_siret',
|
|
979 |
'html_inputmode': 'number'}
|
|
980 |
),
|
|
981 |
('nir-fr', {
|
|
982 |
'title': N_('NIR (France)'),
|
|
983 |
'function': 'validate_nir',
|
|
984 |
'html_inputmode': 'number'}
|
|
985 |
),
|
|
986 |
('iban', {
|
|
987 |
'title': N_('IBAN'),
|
|
988 |
'function': 'validate_iban',
|
|
989 |
'html_inputmode': 'number'}
|
|
990 |
),
|
961 |
991 |
('regex', {'title': N_('Regular Expression')}),
|
962 |
992 |
('django', {'title': N_('Django Condition')}),
|
963 |
993 |
])
|
... | ... | |
1036 |
1066 |
return validation_method.get('html_input_type')
|
1037 |
1067 |
return 'text'
|
1038 |
1068 |
|
|
1069 |
@classmethod
|
|
1070 |
def get_html_inputmode(cls, validation):
|
|
1071 |
validation_method = cls.validation_methods.get(validation['type'])
|
|
1072 |
if validation_method and validation_method.get('html_inputmode'):
|
|
1073 |
return validation_method.get('html_inputmode')
|
|
1074 |
|
1039 |
1075 |
|
1040 |
1076 |
class WcsExtraStringWidget(StringWidget):
|
1041 |
1077 |
field = None
|
... | ... | |
1049 |
1085 |
def render_content(self):
|
1050 |
1086 |
if self.field and self.field.validation:
|
1051 |
1087 |
self.HTML_TYPE = ValidationWidget.get_html_input_type(self.field.validation)
|
|
1088 |
self.inputmode = ValidationWidget.get_html_inputmode(self.field.validation)
|
1052 |
1089 |
return super(WcsExtraStringWidget, self).render_content()
|
1053 |
1090 |
|
1054 |
1091 |
def _parse(self, request):
|
1055 |
|
-
|