Unsure how to have certain form answers stop you from progressing to next page

180 views
Skip to first unread message

Henry Stowell

unread,
Mar 15, 2022, 10:37:55 AM3/15/22
to oTree help & discussion
I am having issues with how to use a consent form with "Yes I consent" and "No I don't consent" answers.

How can I use this form so that you can only progress to the next page by clicking "Yes I consent"

Thank you

Chris Crabbe

unread,
Mar 15, 2022, 11:58:09 AM3/15/22
to Henry Stowell, oTree help & discussion
Hi Henry -

The way I would do this would be to implement the error_message method for that form field:  https://otree.readthedocs.io/en/latest/forms.html#field-name-error-message

Thanks,
--Chris

--
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/46b1ed40-d9c2-4d35-946a-c2ab0711e130n%40googlegroups.com.

Henry Stowell

unread,
Mar 15, 2022, 12:25:29 PM3/15/22
to oTree help & discussion
I have edited and added said code from the documentation page but I still seem to be getting the same result. Participants are allowed to the next page even if they have selected the no consent option. My code is below:

Consent code.png

Where am I going wrong? I am fairly new to Python so may be making some simple mistake here

Chris Crabbe

unread,
Mar 15, 2022, 1:07:09 PM3/15/22
to Henry Stowell, oTree help & discussion
Hi Henry -

You're comparing player.consent, which hasn't been set any value yet when error_message is called.  You should compare to the "value" variable passed as an argument to error_message.

(I still absent-mindedly make this mistake sometimes after all these years, so don't feel bad about it).  Good luck!

Thanks,
--Chris

Reply all
Reply to author
Forward
0 new messages