Closed (fixed)
Project:
Custom Field
Version:
3.1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Apr 2025 at 09:55 UTC
Updated:
14 Apr 2025 at 23:24 UTC
Jump to comment: Most recent
For a custom field of type numeric, one cannot set both min and max field values. (I've tried this with the decimal numeric field type.) If you do set both, when saving the content, it leads to the following error message:
The website encountered an unexpected error. Try again later.
Symfony\Component\Validator\Exception\ConstraintDefinitionException: The "Drupal\Core\Validation\Plugin\Validation\Constraint\RangeConstraint" constraint can not use "minMessage" and "maxMessage" when the "min" and "max" options are both set. Use "notInRangeMessage" instead. in Symfony\Component\Validator\Constraints\Range->__construct() (line 103 of /.../vendor/symfony/validator/Constraints/Range.php).
I suppose the problem is with the public function getConstraints(array $settings): (in DecimalType.php) which provides validations for the min / max parameters only when set separately.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
marksmith commentedThe following code appears to solve the issue:
I suppose, something similar should also be added to the IntegerType.php as well.
Comment #3
apmsooner commentedOkay thanks for the report. I'll put together a patch soon for this issue.
Comment #5
apmsooner commentedTry the patch please.
Comment #6
apmsooner commentedComment #8
apmsooner commented