When attempting to save field settings for an integer 'Select (or other) list', if the default value is set to '- Select a value -' which it is by default, the configuration form will report the error:

Value must be a valid integer.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Rory’s picture

Title: Integer field settings validates '- Select a value -' default value » Integer / float field settings validates '- Select a value -' default value

The same form error appears if working with floats.

Value must be a valid integer or decimal.

The default value of '- Select a value -' should be accepted.

As this is related to default values configured under field settings it might be related to #1494948: Default value isn't selected by default.

danielb’s picture

confirmed

danielb’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

ashrafabed’s picture

I was still finding this error in the latest version, so I made this small edit:

select_or_other.field_widget.inc

-  if ($field_info['type'] == 'number_integer' && !preg_match('/^-?\d+$/', $v)) {
+  if ($field_info['type'] == 'number_integer' && !preg_match('/^-?\d+$/', $v) && $v != '_none') {
          form_error($element, t('!name field must be a valid integer.', array('%name' => t($element['select']['#title']))));
          break;
        }
haydeniv’s picture

Status: Closed (fixed) » Active

This will get lost without an active status.

mrfelton’s picture

Status: Active » Needs review
FileSize
658 bytes

Patch to that effect.

haydeniv’s picture

Status: Needs review » Needs work

This does not apply to the latest dev anymore. Also this should also apply to number_float and number_decimal as well correct?

Hydra’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
715 bytes
haydeniv’s picture

Status: Needs review » Fixed

Committed: cd56ce8

Thanks.

Status: Fixed » Closed (fixed)

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

  • Commit 6cd3bf5 on 7.x-2.x, 7.x-3.x, 8.x-3.x by danielb:
    Issue #1494954 by danielb: numeric validation problem.
    
    
troybthompson’s picture

Status: Closed (fixed) » Needs work

I'm still having this issue using 7.x-2.22 on a Decimal field and trying to set the default value as "unknown" and the patched code above seems to be there.

Also, when I test it on an integer field in this patch, I get the error:

Notice: Undefined index: value in number_field_validate() (line 137 of /usr/www/users/daedal/socialweb/modules/field/modules/number/number.module).
Notice: Undefined index: value in number_field_is_empty() (line 173 of /usr/www/users/daedal/socialweb/modules/field/modules/number/number.module).

Thoughts?

legolasbo’s picture

Version: 7.x-2.8 » 7.x-2.22

  • danielb committed 6cd3bf5 on 8.x-1.x
    Issue #1494954 by danielb: numeric validation problem.
    
    
cmseasy’s picture

Component: CCK / Field API widget » Field widget (non-specific or listed)
Status: Needs work » Active

Reopening.

Using version = "7.x-2.22",: I have the same error as the original issue:

When attempting to save field settings for an integer 'Select (or other) list', if the default value is set to '- Select a value -' which it is by default, the configuration form will report the error:

Value must be a valid integer.

The patched line from #9 is present in the code.

daften’s picture

Status: Active » Closed (outdated)

Closing as outdated because no activity in a long time and Drupal 7 goes EOL soon. Feel free to re-open if needed.