I can't get form-table of '#type' => 'tableselect' to work. I've lifted the example from 8.3.x core/lib/Drupal/Core/Render/Element/Tableselect.php Tableselect. The table works and there are no log messages.
What happens is the page reports that there are no users found (ie. the table is empty) even though the $form array has the row data in it.
If I change the type to '#type' => 'table' the table is populated as expected.
This is the code I am using.
namespace Drupal\simpleForm\Controller;
use Drupal\Core\Controller\ControllerBase;
class DisplayTable_1 extends ControllerBase
{
public function description_one()
{
$header = [
'first_name' => $this->t('First Name'),
'last_name' => $this->t('Last Name'),
];
$options = [
1 => ['first_name' => 'Indy', 'last_name' => 'Jones'],
2 => ['first_name' => 'Darth', 'last_name' => 'Vader'],
3 => ['first_name' => 'Super', 'last_name' => 'Man'],
];
$form['table'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => $this->t('No users found!!!'),
);
return $form;
}
}
Any help would be appreciated.