formdata: add a varnames_only variant to get_dict_with_varnames (#7132)
This commit is contained in:
parent
2ca498b63f
commit
e65b09fb2f
|
@ -30,7 +30,7 @@ from qommon.substitution import Substitutions
|
|||
from roles import Role
|
||||
|
||||
|
||||
def get_dict_with_varnames(fields, data, formdata=None):
|
||||
def get_dict_with_varnames(fields, data, formdata=None, varnames_only=False):
|
||||
new_data = {}
|
||||
for field in fields:
|
||||
if not hasattr(field, 'get_view_value'):
|
||||
|
@ -43,12 +43,14 @@ def get_dict_with_varnames(fields, data, formdata=None):
|
|||
else:
|
||||
value = ''
|
||||
display_value = ''
|
||||
# add it as f$n$
|
||||
new_data['f%s' % field.id] = value
|
||||
|
||||
# also add it as 'field_' + normalized(field label)
|
||||
identifier_name = qommon.misc.simplify(field.label, space = '_')
|
||||
new_data['field_' + identifier_name] = value
|
||||
if not varnames_only:
|
||||
# add it as f$n$
|
||||
new_data['f%s' % field.id] = value
|
||||
|
||||
# also add it as 'field_' + normalized(field label)
|
||||
identifier_name = qommon.misc.simplify(field.label, space = '_')
|
||||
new_data['field_' + identifier_name] = value
|
||||
|
||||
# and finally add it as its manually defined variable name
|
||||
if field.varname:
|
||||
|
|
Loading…
Reference in New Issue