When adding new Numeric Webform Validation and not specifying a numeric range, I get the following error:

Notice: Undefined variable: range in clientside_validation_webform_add_webform_validation() (line 104 of \sites\all\modules\clientside_validation\clientside_validation_webform\clientside_validation_webform.module).

Looking at the code there it appears that the $range variable is not initialized outside of the if (strpos($data, '|') !== FALSE) statement. So if you do not define a range it attemps to use the non-existent $range variable in the clientside_validation_set_minmax() function call.

A similar error occurs when you only define only a min or a max (and not both) since one of the array keys is undefined in those cases.

Even with that warning aside, there does not appear to be any validation function in the clientside validation module to just check if the field is numeric.

Let me know if this makes sense. I will be happy to help troubleshoot and correct these issues.

I am using the following versions of the modules:
Clientside Validation module version 7.x-1.x-dev (build date of 9/22/2011).
Webform Validation module version 7.x-1.0
Webform module version 7.x-3.11

Comments

hooface’s picture

subscribe

attiks’s picture

Latest dev version contains the following, was fixed by this commit

        case 'numeric':
          $data = $webform_validation_rule['data'];
          $range = array('min' => NULL, 'max' => NULL);
          if (strpos($data, '|') !== FALSE) {

attiks’s picture

Status: Active » Fixed

if not, re-open

beefheartfan’s picture

Status: Fixed » Needs work

Attiks, thanks for the quick update.

However, your newly committed code still misses one test case. In Webform Validator, if you want to set a numeric minimum and not a maximum you only need to type a number into the Range field. Thus, fields that only have a minimum value do not contain the '|' and are missed by the validation.

Code such as this I believe will fix the issue:

          if (strpos($data, '|') !== FALSE) {
            list($min, $max) = explode('|', $data);
            if ($min != '' && is_numeric($min)) {
              $range['min'] = (int) $min;
            }
            if ($max != '' && is_numeric($max)) {
              $range['max'] = (int) $max;
            }
          }
	 else {
			if ($data != '' && is_numeric($data)) {
				$range['min'] = (int) $data;
			}
		  }
          foreach ($webform_validation_rule['components'] as $component) {
attiks’s picture

Assigned: Unassigned » Jelle_S

@beefheartfan: I knew already, but didn't have time to add it, we'll add your code somewhere tomorrow, your fix looks good.

Jelle_S’s picture

Assigned: Jelle_S » Unassigned
Status: Needs work » Fixed

Fixed in latest dev version

Status: Fixed » Closed (fixed)

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