#1
by
AndreL
I have a long quiz with 10 questions in one page. Each have their own validation rules. Is there a convenient way in oTree Lite to place the field error message next to the form field where it happened, other than: ============================================== {{ formfield 'my_field1' }} {{ formfield_errors 'my_field1' }} {{ formfield 'my_field2' }} {{ formfield_errors 'my_field2' }} {{ formfield 'my_field3' }} {{ formfield_errors 'my_field3' }} ... =================================================
#2
by
Chris_oTree
The formfield element already includes the errors, so the formfield_errors is redundant here, no? And then that can be reduced to {{ formfields }}.
#3
by
AndreL
Yes, but if I use {{ formfields }}, it will display the error message at the top of the block, not right before the question that is wrong. Or am I doing something wrong?
#4
by
Chris_oTree
If you want the errors next to the field, you should use FIELD_error_message, not error_message: https://otree.readthedocs.io/en/latest/forms.html#field-name-error-message Or you can use this technique if you have many fields: https://otree.readthedocs.io/en/latest/misc/tips_and_tricks.html#duplicate-validation-methods