tableselect form doesn't work 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' =&gt; $this-&gt;t('First Name'),
            'last_name' =&gt; $this-&gt;t('Last Name'),
        ];

        $options = [
            1 =&gt; ['first_name' =&gt; 'Indy', 'last_name' =&gt; 'Jones'],
            2 =&gt; ['first_name' =&gt; 'Darth', 'last_name' =&gt; 'Vader'],
            3 =&gt; ['first_name' =&gt; 'Super', 'last_name' =&gt; 'Man'],
        ];

        $form['table'] = array(
            '#type' =&gt; 'tableselect',
            '#header' =&gt; $header,
            '#options' =&gt; $options,
            '#empty' =&gt; $this-&gt;t('No users found!!!'),
        );

        return $form;
    }

}


Any help would be appreciated.
Found the issue: the #type' => 'tableselect has to be built inside a class that extends FormBase.

This Works:

  class DisplayTable_1 extends FormBase {
    public function buildForm(array $form, FormStateInterface $form_state)
    {
        $options = [
            1 =&gt; ['first_name' =&gt; 'Indy', 'last_name' =&gt; 'Jones'],
            2 =&gt; ['first_name' =&gt; 'Darth', 'last_name' =&gt; 'Vader'],
            3 =&gt; ['first_name' =&gt; 'Super', 'last_name' =&gt; 'Man'],
        ];

        $header = [
            'first_name' =&gt; t('First Name'),
            'last_name' =&gt; t('Last Name'),
        ];

        $form['table'] = [
            '#type' =&gt; 'tableselect',
            '#title' =&gt; $this-&gt;t('Users'),
            '#header' =&gt; $header,
            '#options' =&gt; $options,
            '#empty' =&gt; t('No users found'),
        ];

        // Add a submit button that handles the submission of the form.
        $form['actions']['submit'] = [
            '#type' =&gt; 'submit',
            '#value' =&gt; $this-&gt;t('Submit'),
            '#description' =&gt; $this-&gt;t('Submit, #type = submit'),
        ];
        return $form;
    }

    public function getFormId() {
        return 'fapi_example_input_demo_form';
    }

    public function submitForm(array &amp;$form, FormStateInterface $form_state) {
        // Find out what was submitted.
        $values = $form_state-&gt;getValues();
        foreach ($values as $key =&gt; $value) {
            $label = isset($form[$key]['#title']) ? $form[$key]['#title'] : $key;

            // Many arrays return 0 for unselected values so lets filter that out.
            if (is_array($value)) {
                $value = array_filter($value);
            }

            // Only display for controls that have titles and values.
            if ($value &amp;&amp; $label) {
                $display_value = is_array($value) ? preg_replace('/[\n\r\s]+/', ' ', print_r($value, 1)) : $value;
                $message = $this-&gt;t('Value for %title: %value', array('%title' =&gt; $label, '%value' =&gt; $display_value));
                drupal_set_message($message);
            }
        }
    }
}