#1 by Fanist
Hey guys! I wanna add a voluntary question for participants, which stores input as float when there is input and "None" when there is not. I try to use field_maybe_none() to achieve my goal but I did not quite understand its usage. In otree doc, the code is: # instead of player.abc, do: abc = player.field_maybe_none('abc') But I guess it is a way to get the value from an existing variable "player.abc", right? How can I store the data in form fields? Thanks!
#2 by jkemp
You can make a field optional by adding blank = True when you define your field. Then you include the field on your HTML page just as you always do, but the field is now optional. E.g.: class Player(BasePlayer): abc = models.FloatField(blank = True) See the documentation here: https://otree.readthedocs.io/en/latest/forms.html#optional-fields
#3 by Fanist
Thanks a lot, it works!