Form validation in quiz?

Events happening in the community are now at Drupal community events on www.drupal.org.
mpearrow's picture

Hi all,

I am hoping to use form element validation for one of my question types. I have a textarea that should pass some validation before the user can submit (doing syntax checking before they commit something that is bound to be scored poorly). I have been able to create a _validate function in my question_type.module file, and it appears to fire when the user clicks "next" or "finish".

However, the form_set_error() that is inside my validate function appears to not be doing what I'd expect: the question gets submitted even though a form_set_error happens and the validated field gets highlighted in red. The quiz advances to the next question anyway, as if the error didn't happen, and the field on the next question gets highlighted.

If I understand correctly, the validate function should get called before submit happens, and if form_set_error happens, the submit should not happen and the user should stay on the current question. What am I missing?

Quiz

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week