|
|
@ -1,3 +1,5 @@ |
|
|
|
|
|
|
|
# -*- coding: utf8 -*- |
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
""" |
|
|
|
FormRender takes care of the rendering of forms to HTML. |
|
|
|
FormRender takes care of the rendering of forms to HTML. |
|
|
|
""" |
|
|
|
""" |
|
|
@ -22,6 +24,8 @@ HTML_FIELD_CHECKBOX = u''' |
|
|
|
</li> |
|
|
|
</li> |
|
|
|
''' |
|
|
|
''' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HTML_REQUIRED = u'''{} <abbr title="This field is required" class="required">•</span>''' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FormRender(object): |
|
|
|
class FormRender(object): |
|
|
|
""" |
|
|
|
""" |
|
|
@ -96,7 +100,12 @@ class FormRender(object): |
|
|
|
params = self.cast_params(kwargs) |
|
|
|
params = self.cast_params(kwargs) |
|
|
|
method_name = 'r_field_{0}'.format(field_type) |
|
|
|
method_name = 'r_field_{0}'.format(field_type) |
|
|
|
method = getattr(self, method_name, None) |
|
|
|
method = getattr(self, method_name, None) |
|
|
|
return method(**params) |
|
|
|
field = method(**params) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'required' in kwargs and kwargs['required'] is True: |
|
|
|
|
|
|
|
return HTML_REQUIRED.format(field) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
return field |
|
|
|
|
|
|
|
|
|
|
|
def r_field_string(self, name, value, minlen=None, maxlen=None, size=50, |
|
|
|
def r_field_string(self, name, value, minlen=None, maxlen=None, size=50, |
|
|
|
required=False, classes=None, style=""): |
|
|
|
required=False, classes=None, style=""): |
|
|
|