diff --git a/molo/surveys/forms.py b/molo/surveys/forms.py index 24c7dd1..1d35e24 100644 --- a/molo/surveys/forms.py +++ b/molo/surveys/forms.py @@ -252,6 +252,7 @@ def clean(self): 'Options: a True and False'), ) elif data['field_type'] in VALID_SKIP_LOGIC: + choice_max_length = 0 for i, logic in enumerate(data['skip_logic']): if not logic.value['choice']: self.add_stream_field_error( @@ -259,6 +260,19 @@ def clean(self): 'choice', _('This field is required.'), ) + else: + choice_max_length += len(logic.value['choice']) + + if choice_max_length > CHARACTER_COUNT_CHOICE_LIMIT: + err = 'The combined choices\' maximum characters ' \ + 'limit has been exceeded ({max_limit} '\ + 'character(s)).' + + self.add_form_field_error( + 'field_type', + _(err).format( + max_length=CHARACTER_COUNT_CHOICE_LIMIT), + ) for i, logic in enumerate(data['skip_logic']): if logic.value['skip_logic'] == SkipState.SURVEY: