Problem/Motivation
Generating decimal values does not respect the min and max values.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21P...
$max = is_numeric($settings['max']) ?: pow(10, ($precision - $scale)) - 1;
$min = is_numeric($settings['min']) ?: -pow(10, ($precision - $scale)) + 1;
This should be turned into normal ternary operator because is_numeric() returns boolean value.
Steps to reproduce
Steps to reproduce.
- Add field of type Number (Decimal) to some content type
- Set minimum and maximum options for this field
- Generate sample data using Devel generate module
- Verify that generated value for this field is always 1.00.
Proposed resolution
Change the min/max for float and decimal to something like this:
$max = is_numeric($settings['max']) ? $settings['max'] : pow(10, ($precision - $scale)) - 1;
$min = is_numeric($settings['min']) ? $settings['min'] : -pow(10, ($precision - $scale)) + 1;
Remaining tasks
Review
Commit
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
N/A