#1
by
frieder_neunhoeffer
Hi,
I would like to add a variable to the label of another formfield. It works if it's only the variable (see Template below), but I would like to nest it into a sentence (see Template1 below). Obviously, I get an error. I've tried already many alternatives, but couldn't find a solution. Any ideas are very welcome (: Thanks
models.py:
class Player(BasePlayer):
guess_upside = models.PositiveIntegerField()
prob_upside = models.PositiveIntegerField()
Template:
{{ formfield 'prob_upside' label=player.guess_upside}}
Template1:
{{ formfield 'prob_upside' label=Why did you guess player.guess_upside?}}
#2
by
Chris_oTree
See here: https://otree.readthedocs.io/en/latest/forms.html#form-fields-with-dynamic-labels
#3
by
frieder_neunhoeffer
Hi Chris,
thanks a lot for your reply. However, there is another issue now.
I would like to use the input variable from another precedent app.
Following the documentation, I put
@staticmethod
def vars_for_template(player):
return dict(
criteria_label='Why did you choose'.format(player.participant.guess_upside)
)
but the actual page only shows "Why did you choose" without adding the value for guess_upside variable.
Do you have an idea how to solve that?
Thanks in advance,
Frieder