If I have a select field in D7 containing the numbers 0-10 as options, and configure the default value to be "0", that default will not be migrated, as "0" is a falsy value. empty("0")
returns TRUE.
There are probably other settings where this mistake is made.
if (!empty(trim($element['value'])) && (empty($valid_options) || in_array($element['value'], $valid_options))) {
$new_element['#default_value'] = trim($element['value']);
}
if (!empty($extra['field_prefix'])) {
$new_element['#field_prefix'] = $extra['field_prefix'];
}
if (!empty($extra['field_suffix'])) {
$new_element['#field_suffix'] = $extra['field_suffix'];
}
...
if (!empty($extra['description'])) {
$new_element['#description'] = $extra['description'];
}
All of these should allow "0" as valid values. It's possible to set "0" or "0.0" as prefix and suffix as well.
if (trim($element['value']) !== '' && (empty($valid_options) || in_array($element['value'], $valid_options))) {
$new_element['#default_value'] = trim($element['value']);
}
if (isset($extra['field_prefix'])) {
$new_element['#field_prefix'] = $extra['field_prefix'];
}
if (isset($extra['field_suffix'])) {
$new_element['#field_suffix'] = $extra['field_suffix'];
}
...
if (isset($extra['description'])) {
$new_element['#description'] = $extra['description'];
}
Needs review
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.