help: add paragraph about item field substitution variables
This commit is contained in:
parent
ba9827f31f
commit
98436f1e7c
|
@ -186,6 +186,13 @@ champs, etc.
|
|||
champ</var></code> (par exemple : <code>form_var_courriel</code>).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Pour les champs de type « Liste » qui contiendraient à la fois un libellé
|
||||
et un identifiant, le libellé se trouvera dans <code>form_var_<var>variable
|
||||
du champ</var></code> et l'identifiant dans <code>form_var_<var>variable du
|
||||
champ</var>_raw</code>.
|
||||
</p>
|
||||
|
||||
</section>
|
||||
|
||||
<section id="workflow-data">
|
||||
|
|
|
@ -306,3 +306,22 @@ def test_criticality_levels(pub):
|
|||
d.criticality_level = 104
|
||||
d.decrease_criticality_level()
|
||||
assert d.get_criticality_level_object().name == 'green'
|
||||
|
||||
def test_field_item_substvars(pub):
|
||||
ds = {
|
||||
'type': 'formula',
|
||||
'value': repr([('1', 'un'), ('2', 'deux')]),
|
||||
}
|
||||
|
||||
formdef = FormDef()
|
||||
formdef.name = 'foobar'
|
||||
formdef.fields = [fields.ItemField(id='0', label='string', data_source=ds,
|
||||
varname='xxx')]
|
||||
formdef.store()
|
||||
|
||||
formdata = formdef.data_class()()
|
||||
formdata.data = {'0': '1', '0_display': 'un'}
|
||||
|
||||
variables = formdata.get_substitution_variables()
|
||||
assert variables.get('form_var_xxx') == 'un'
|
||||
assert variables.get('form_var_xxx_raw') == '1'
|
||||
|
|
Loading…
Reference in New Issue