add form_var_xxx_raw substitution vars (fix #1777)

When N_display exists, there is now two substitutions variables:
* form_var_xxx contains N_display
* form_var_xxx_raw contains N
Currently usefull with data_sources in ItemField (list).
This commit is contained in:
Thomas NOËL 2012-10-16 14:33:13 +02:00
parent 69c6490f8c
commit 37521e0112
1 changed files with 7 additions and 3 deletions

View File

@ -29,11 +29,13 @@ def get_dict_with_varnames(fields, data):
new_data = {}
for field in fields:
if data is not None:
value = data.get(field.id)
raw_value = data.get(field.id)
if field.convert_value_to_str:
value = field.convert_value_to_str(value)
raw_value = field.convert_value_to_str(raw_value)
else:
value = ''
raw_value = ''
display_value = data.get('%s_display' % field.id)
value = display_value or raw_value
# add it as f$n$
new_data['f%s' % field.id] = value
@ -44,6 +46,8 @@ def get_dict_with_varnames(fields, data):
# and finally add it as its manually defined variable name
if field.varname:
new_data['var_%s' % field.varname] = value
if display_value:
new_data['var_%s_raw' % field.varname] = raw_value
return new_data