I am creating a table form using the table element. I do not push sub elements into #rows. I work as with children elements. But valueCallback does not map values right. I am looking inside. It looks very strange. Especially:
return is_array($input) ? array_combine($input, $input) : [];
$input always is array. So combining result is weird with "array" key https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21Table.php/function/Table%3A%3AvalueCallback/8.5.x
public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
// If #multiple is FALSE, the regular default value of radio buttons is used.
if (!empty($element['#tableselect']) && !empty($element['#multiple'])) {
// Contrary to #type 'checkboxes', the default value of checkboxes in a
// table is built from the array keys (instead of array values) of the
// #default_value property.
// @todo D8: Remove this inconsistency.
if ($input === FALSE) {
$element += [
'#default_value' => [],
];
$value = array_keys(array_filter($element['#default_value']));
return array_combine($value, $value);
}
else {
return is_array($input) ? array_combine($input, $input) : [];
}
}
}
For me $input already is ready to move into #value. It does not need altering here. I hope it works well and I do something wrong. But not it seems weird for. Clarify it, please.