Fill table with data on submit I created a submit button in my config form.

$form['actions']['find_users']  = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('Find users'),
        '#submit' =&gt; array('::find_users'),
      );


When I press on submit button, I need to create a table and fill it with the all users of my forum.

First, I created this function:

function find_users(array &amp;$form, FormStateInterface $form_state) {
        $header = [
                    'username' =&gt; t('username'),
                    'registered' =&gt; t('registered'),
                      'email' =&gt; t('e-mail'),
                    'ip' =&gt; t('ip'),
                      'last_visit' =&gt; t('last visit'),
                  ];


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


But when I press on my submit button, table doesn't create. What should I do?

For example, I need to fill table with just the first record from users_field_data table (limit 1).
You're missing #options property in your tableselect element, e.g.

$form['table'] = array(
  '#type' =&gt; 'tableselect',
  '#header' =&gt; $header,
  '#options' =&gt; $options,
  '#multiple' =&gt; FALSE,
);


See: Adding checkboxes to a table.