otree fromfield error

398 views
Skip to first unread message

rajib prasad

unread,
May 2, 2022, 2:36:15 PM5/2/22
to oTree help & discussion
I am getting an error, which I did not face before though I defined the formfield tag as usual notation. The error I am getting is :

Debug info

The form field vote2 has errors, but its error message is not being displayed, possibly because you did not include the field in the template. There are 2 ways to fix this:

  1. Include the field with the formfield tag, e.g. {{ formfield "vote2" }}
  2. If you are not using formfield but are instead writing the raw HTML for the form input, remember to include {{ formfield_errors 'vote2' }} somewhere in your page's HTML
I am sharing the portion of the code and the screen shot of the error. I tried various things but could not resolve it. Can anyone pleas help me out??

I have defined two player level fields as follows:
vote1 = models.IntegerField(
choices=[
[1, "PLAYER A"],
[2, "PLAYER B"],
[3, "PLAYER C"],
], label="Which player do you like to select as delegate in group group?"
)

vote2 = models.IntegerField(
choices=[
[1, "PLAYER D"],
[2, "PLAYER E"],
[3, "PLAYER F"],
], label="Which player do you like to select as delegate in group group?"
)

And in HTML I have my code for the page as follows:

{{ if player.subgroup_id == 1 }}
{{ formfield 'vote1' }}

{{ elif player.subgroup_id == 2 }}
{{ formfield 'vote2' }}
{{ else }}
{{ endif }}


Selection_038.png

Chris @ oTree

unread,
May 2, 2022, 3:59:40 PM5/2/22
to rajib prasad, oTree help & discussion
Use get_form_fields to only return the form fields that get shown based on your dynamic condition. 

Sent from my phone

On May 3, 2022, at 2:36 AM, rajib prasad <rwho...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/face13be-3a0c-4fe4-8713-0826c91715f2n%40googlegroups.com.
Selection_038.png

rajib prasad

unread,
May 2, 2022, 4:34:40 PM5/2/22
to Chris @ oTree, oTree help & discussion
Thank you, I will do that. 
Selection_038.png
Reply all
Reply to author
Forward
0 new messages