function webform_update_8103 in Webform 8.5
Same name and namespace in other branches
- 6.x includes/webform.install.update.inc \webform_update_8103()
Issue #2939948: Date fields should respect #min and #max in test-mode. Remove hard-coded test date values.
File
- includes/
webform.install.update.inc, line 1953 - Archived Webform update hooks.
Code
function webform_update_8103() {
$test_date_elements = [
'date',
'datetime',
'datelist',
];
$test_date_values = [
'1942-06-18',
'1940-07-07',
'1943-02-25',
'1940-10-09',
];
$config = \Drupal::configFactory()
->getEditable('webform.settings');
$data = $config
->getRawData();
$types = Yaml::decode($data['test']['types']);
foreach ($test_date_elements as $test_date_element) {
if (isset($types[$test_date_element]) && $types[$test_date_element] === $test_date_values) {
unset($types[$test_date_element]);
}
}
$data['test']['types'] = Yaml::encode($types);
$config
->setData($data);
$config
->save();
}