Add min/max options to integer fields in farm_field.factory #768
This commit is contained in:
parent
5f09c940c1
commit
68ae993c41
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## [3.0.0] 2024-01-05
|
||||||
|
|
||||||
This is the first "stable" release of farmOS v3. See the release notes for
|
This is the first "stable" release of farmOS v3. See the release notes for
|
||||||
|
|
|
@ -142,6 +142,8 @@ Both methods expect an array of field definition options. These include:
|
||||||
- `integer` - Integer number. Additional options:
|
- `integer` - Integer number. Additional options:
|
||||||
- `size` (optional) - The integer database column size (`tiny`,
|
- `size` (optional) - The integer database column size (`tiny`,
|
||||||
`small`, `medium`, `normal`, or `big`). Defaults to `normal`.
|
`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:
|
- `list_string` - Select list with allowed values. Additional options:
|
||||||
- `allowed_values` - An associative array of allowed values.
|
- `allowed_values` - An associative array of allowed values.
|
||||||
- `allowed_values_function` - The name of a function that returns an
|
- `allowed_values_function` - The name of a function that returns an
|
||||||
|
|
|
@ -781,6 +781,14 @@ class FarmFieldFactory implements FarmFieldFactoryInterface {
|
||||||
$field->setSetting('size', $options['size']);
|
$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.
|
// Build form and view display settings.
|
||||||
$field->setDisplayOptions('form', [
|
$field->setDisplayOptions('form', [
|
||||||
'type' => 'number',
|
'type' => 'number',
|
||||||
|
|
Loading…
Reference in New Issue