Add min/max options to integer fields in farm_field.factory #768

This commit is contained in:
Michael Stenta 2024-01-09 06:28:53 -05:00
parent 5f09c940c1
commit 68ae993c41
3 changed files with 14 additions and 0 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- [Add min/max options to integer fields in farm_field.factory #768](https://github.com/farmOS/farmOS/pull/768)
## [3.0.0] 2024-01-05
This is the first "stable" release of farmOS v3. See the release notes for

View File

@ -142,6 +142,8 @@ Both methods expect an array of field definition options. These include:
- `integer` - Integer number. Additional options:
- `size` (optional) - The integer database column size (`tiny`,
`small`, `medium`, `normal`, or `big`). Defaults to `normal`.
- `min` (optional) - The minimum value.
- `max` (optional) - The maximum value.
- `list_string` - Select list with allowed values. Additional options:
- `allowed_values` - An associative array of allowed values.
- `allowed_values_function` - The name of a function that returns an

View File

@ -781,6 +781,14 @@ class FarmFieldFactory implements FarmFieldFactoryInterface {
$field->setSetting('size', $options['size']);
}
// Set the min/max constraints, if specified.
if (isset($options['min'])) {
$field->setSetting('min', $options['min']);
}
if (isset($options['max'])) {
$field->setSetting('max', $options['max']);
}
// Build form and view display settings.
$field->setDisplayOptions('form', [
'type' => 'number',