The description on the validator creation screen says $value and $arg are the proper things to use in the PHP validator, but when I read the source, I see (lines 375-378)

            $substitutes['%field'] = $element['#name'];
            if (isset($arg)) {
              $substitutes['%arg'] = $arg;
            }

which is similar to what's in the regex validation case. What is the point of those in the PHP validator?

Comments

TapocoL’s picture

Status: Active » Closed (works as designed)

PHP uses eval(), so on line 362-365 on Rev 1.16 in validation_api.module:

      $value = (is_array($element['#value']) ? $element['#value']['value'] : $element['#value']);
      if (isset($va_field->arg)) {
        $arg = $va_field->arg;
      }

So, these are the variables you can use in the eval of your rule/PHP Code. Case 'regex' uses the str_replace to replace %arg with the value of $arg.