mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
Set the minimum value of maturity_days and transplant_days to 1.
This commit is contained in:
parent
78e1aad0d5
commit
ff89fb7a34
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- [Set the minimum value of maturity_days and transplant_days to 1 #794](https://github.com/farmOS/farmOS/pull/794)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- [Check for correct update operation access in location hierarchy form #800](https://github.com/farmOS/farmOS/pull/800)
|
- [Check for correct update operation access in location hierarchy form #800](https://github.com/farmOS/farmOS/pull/800)
|
||||||
|
|
|
@ -18,7 +18,7 @@ translatable: false
|
||||||
default_value: { }
|
default_value: { }
|
||||||
default_value_callback: ''
|
default_value_callback: ''
|
||||||
settings:
|
settings:
|
||||||
min: null
|
min: 1
|
||||||
max: null
|
max: null
|
||||||
prefix: ''
|
prefix: ''
|
||||||
suffix: ' day| days'
|
suffix: ' day| days'
|
||||||
|
|
|
@ -18,7 +18,7 @@ translatable: false
|
||||||
default_value: { }
|
default_value: { }
|
||||||
default_value_callback: ''
|
default_value_callback: ''
|
||||||
settings:
|
settings:
|
||||||
min: null
|
min: 1
|
||||||
max: null
|
max: null
|
||||||
prefix: ''
|
prefix: ''
|
||||||
suffix: ' day| days'
|
suffix: ' day| days'
|
||||||
|
|
38
modules/taxonomy/plant_type/farm_plant_type.post_update.php
Normal file
38
modules/taxonomy/plant_type/farm_plant_type.post_update.php
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Post update hooks for the farm_plant_type module.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Drupal\field\Entity\FieldConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the minimum value of maturity_days and transplant_days to 1.
|
||||||
|
*/
|
||||||
|
function farm_plant_type_post_update_min_1_day(&$sandbox) {
|
||||||
|
|
||||||
|
// Set the min setting of both fields to 1.
|
||||||
|
$field_names = [
|
||||||
|
'maturity_days',
|
||||||
|
'transplant_days',
|
||||||
|
];
|
||||||
|
foreach ($field_names as $field_name) {
|
||||||
|
$field = FieldConfig::load('taxonomy_term.plant_type.' . $field_name);
|
||||||
|
if (!empty($field)) {
|
||||||
|
$field->setSetting('min', 1);
|
||||||
|
$field->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete any zero values from the database.
|
||||||
|
$tables = [
|
||||||
|
'taxonomy_term__maturity_days' => 'maturity_days_value',
|
||||||
|
'taxonomy_term__transplant_days' => 'transplant_days_value',
|
||||||
|
'taxonomy_term_revision__maturity_days' => 'maturity_days_value',
|
||||||
|
'taxonomy_term_revision__transplant_days' => 'transplant_days_value',
|
||||||
|
];
|
||||||
|
foreach ($tables as $table => $column) {
|
||||||
|
\Drupal::database()->query('DELETE FROM {' . $table . '} WHERE ' . $column . ' = 0');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue