|
|
@ -615,23 +615,29 @@ class FormRender(): |
|
|
|
|
|
|
|
|
|
|
|
def cast_params(self, params): |
|
|
|
def cast_params(self, params): |
|
|
|
new_params = params.copy() |
|
|
|
new_params = params.copy() |
|
|
|
if not params.get('required', False): |
|
|
|
|
|
|
|
new_params['required'] = "" |
|
|
|
if 'required' in new_params: |
|
|
|
if not params.get('min', False): |
|
|
|
if new_params['required'] == False: |
|
|
|
new_params["min"] = "" |
|
|
|
new_params['required'] = "" |
|
|
|
if not params.get('max', False): |
|
|
|
else: |
|
|
|
new_params["max"] = "" |
|
|
|
new_params["required"] = "required" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'classes' in new_params: |
|
|
|
|
|
|
|
new_params['classes'] = ' '.join(new_params['classes']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'checked' in new_params: |
|
|
|
|
|
|
|
if new_params['checked'] == False: |
|
|
|
|
|
|
|
new_params['checked'] = "" |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
new_params['checked'] = "checked" |
|
|
|
|
|
|
|
|
|
|
|
return new_params |
|
|
|
return new_params |
|
|
|
|
|
|
|
|
|
|
|
def r_field(self, type, **kwargs): |
|
|
|
def r_field(self, type, **kwargs): |
|
|
|
|
|
|
|
params = self.cast_params(kwargs) |
|
|
|
method_name = 'r_field_{0}'.format(type) |
|
|
|
method_name = 'r_field_{0}'.format(type) |
|
|
|
method = getattr(self, method_name, None) |
|
|
|
method = getattr(self, method_name, None) |
|
|
|
return method(**kwargs) |
|
|
|
return method(**params) |
|
|
|
|
|
|
|
|
|
|
|
def r_field_input(self, type, **kwargs): |
|
|
|
|
|
|
|
params = self.cast_params(kwargs) |
|
|
|
|
|
|
|
tpl = self.field_tpl[type] |
|
|
|
|
|
|
|
return tpl.format(**params) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def r_field_string(self, name, value, required=False, classes=[]): |
|
|
|
def r_field_string(self, name, value, required=False, classes=[]): |
|
|
|
tpl = self.field_tpl['string'] |
|
|
|
tpl = self.field_tpl['string'] |
|
|
|