diff --git a/core/modules/options/options.module b/core/modules/options/options.module
index e6ebdbe..0f2ec4a 100644
--- a/core/modules/options/options.module
+++ b/core/modules/options/options.module
@@ -190,6 +190,15 @@ function options_field_settings_form_validate_allowed_values($element, &$form_st
         form_error($element, t('Allowed values list: each key must be a string at most 255 characters long.'));
         break;
       }
+      // PHP is kind of stupid about typecasting. We've passed other validation
+      // so now make sure we have actual integer keys and not strings if this is
+      // an integer list. To do this we have to remove the old keys and replace
+      // them with specific typecast keys.
+      if ($field_type == 'list_integer') {
+        unset($values[$key]);
+        $key = (int) $key;
+        $values[$key] = $value;
+      }
     }
 
     // Prevent removing values currently in use.
