// Prepare the element #parents for the tableselect form element.
// Their values have to be located in child keys (#tree is ignored),
// since Table::validateTable() has to be able to validate whether input
// (for the parent #type 'table' element) has been submitted.
$element_parents =
array_merge($element['#parents'
],
[$key]);
// Since the #parents of the tableselect form element will equal the
// #parents of the row element, prevent FormBuilder from auto-generating
// an #id for the row element, since
// \Drupal\Component\Utility\Html::getUniqueId() would automatically
// append a suffix to the tableselect form element's #id otherwise.
$row['#id'
] = HtmlUtility::
getUniqueId('edit-' .
implode('-',
$element_parents) . '-row'
);
// Do not overwrite manually created children.
if (!
isset($row['select'
])) { // Determine option label; either an assumed 'title' column, or the
// first available column containing a #title or #markup.
// @todo Consider to add an optional $element[$key]['#title_key']
// defaulting to 'title'?
unset($label_element);
$title = NULL;
if (isset($row['title'
]['#type'
]) &&
$row['title'
]['#type'
] == 'label'
) { $label_element = &
$row['title'
];
}