In my usecase I had to check, if the sent value is equal to the given default-value for the specific component. I solved that by writing a new validation rule "not_default_value" in webform_validation.validators.inc:

Added to function webform_validation_webform_validation_validators()

    'not_default_value' => array(
      'name' => "Not default value",
      'component_types' => array(
        'select',
        'textfield',
        'textarea',
        'email',
        'hidden',
      ),
      'custom_error' => TRUE,
      'description' => t('Verifies that the specified component is not the default value for that component.'),
    ),

Added to webform_validation_webform_validation_validate()

      case "not_default_value":
        foreach ($items as $key => $val) {
          if (is_array($val)) {
            $val = _webform_validation_flatten_array($val);
          }
	  if($val == $components[$key]['value']) {
            $errors[$key] = _webform_validation_i18n_error_message($rule);
          }
        }
        return $errors;
        break;

It would be great, if there could be an output for an individual error-class for the specific compontent like "error-defaultvalue", but I don't know how to build that (jet).

CommentFileSizeAuthor
#2 webform_validation_equal_default-1290216-2.patch4.17 KBAnonymous (not verified)
#1 webform_validation_equal_default-1290216.patch1.49 KBAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Status: Patch (to be ported) » Needs review
FileSize
1.49 KB

Sorry - forgot the Patch-File...

Anonymous’s picture

Version: 7.x-1.0 » 7.x-1.1
Status: Needs review » Patch (to be ported)
FileSize
4.17 KB

Rebuilt patch for current module-version (7.x-1.1).

Liam Morland’s picture

Status: Patch (to be ported) » Needs review
svendecabooter’s picture

Category: task » feature
Status: Needs review » Fixed

Thanks for your contribution freudenreichmedia.
The validation rule seems to work fine, so I committed it to the 6.x and 7.x branch.
Sorry for the long wait.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Error-Correction in Text.