Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291172

integer list fields store keys as strings if there are leading zeros

$
0
0

When creating an integer list field,
if you manually add keys that have leading zeros,
then the keys get stored as strings and the data is not properly displayed.

The saved values on the content that are stored in the database are fine however.

To reproduce:

  1. Add a new integer list field to a content type
  2. Manually add keys for example
    01|Jan
    02|Feb
    03|March
  3. Save the field and note that there are no validation errors.
  4. Create a new piece of content and fill in a value for this field.
  5. View the content and note that the key is displayed but not the value.
  6. Edit the content and note that the proper value is not automatically set.

This is due to the fact that the leading zero passes is_numeric validation and passes a regex checking to ensure that all characters are numeric. But PHP typecasts this as a string. We can simply fix this with the patch attached in the comment.


Viewing all articles
Browse latest Browse all 291172

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>