You are here

function scale_collection_form_validate in Quiz 8.4

Same name and namespace in other branches
  1. 8.6 question_types/quiz_scale/quiz_scale.module \scale_collection_form_validate()
  2. 8.5 question_types/quiz_scale/quiz_scale.module \scale_collection_form_validate()
  3. 6.6 question_types/scale/scale.module \scale_collection_form_validate()
  4. 6.4 question_types/scale/scale.module \scale_collection_form_validate()
  5. 7.6 question_types/scale/scale.module \scale_collection_form_validate()
  6. 7 question_types/scale/scale.module \scale_collection_form_validate()
  7. 7.4 question_types/scale/scale.module \scale_collection_form_validate()
  8. 7.5 question_types/scale/scale.module \scale_collection_form_validate()

Validates the scale collection form

1 string reference to 'scale_collection_form_validate'
scale_manage_collection_form in question_types/scale/scale.module
Form for changing and deleting the current users preset answer collections.

File

question_types/scale/scale.module, line 336
The main file for scale.

Code

function scale_collection_form_validate($form, &$form_state) {

  // If the user is trying to create a new collection
  if (drupal_strlen($form_state['values']['collectionnew']['alternative0']) > 0) {

    // If the new collection don't have two alternatives
    if (drupal_strlen($form_state['values']['collectionnew']['alternative1']) == 0) {

      // This can't be replaced by adding #required to the form elements. If we did so we would always have to
      // create a new collection when we press submit
      form_set_error('collectionnew][alternative1', t('New preset must have atleast two alternatives.'));
    }
  }
}