oTree Forum >

Validating multiple fields together: Error message is not displayed

#1 by nathalieroemer

Hi everyone, 

I am trying to validate multiple fields at once with this code:
class Preferences(Page):
    form_model = 'player'
    form_fields = ['pref1', 'pref2', 'pref3', 'pref4', 'pref5', 'pref6']

    def error_message(player, values):
        ## here the first values is the dict and the function tells python to take the values
        dict_values = values.values()
        if sum(dict_values) > 100:
            return 'Your preference weights cannot exceed 100'
 I checked, that the sum is correctly valculated. I can also not get to the next page, however, no error is displayed. Can someone help?
 Thanks a lot!

#2 by Student

Try to comment out @staticmethod.

#3 by nathalieroemer

.. I resolved it but did not knew how to delete the post (my RA has 'solved' a problem by making the errors invisible in the CSS .. which I only figured out after a while..

Write a reply

Set forum username