I have a simple tableselect element inside my form and the tableselect rows are populated using a pager as follows:
$pagerLimit = 10; //default value if nothing is passed in
$query = $this->jobSkillStorage->getQuery();
$query->condition('type', $skillType);
$query->pager($pagerLimit)
$ids = $query->execute();
$jobSkills = $this->jobSkillStorage->loadMultiple($ids);
return $jobSkills;
The pagination limit functions well and only 10 results are returned, however the pagination controls do not show after the tableselect. Please see the full code of how the tableselect was generated.
public function buildForm(array $form, FormStateInterface $form_state) {
$form['vtabs'] = [
'#type' => 'vertical_tabs',
];
$form['tech_skills' = [
'#type' => 'details',
'#title' => $this->t('Tech Skills'),
'#group' => 'vtabs',
'tech_skills_table' => [
'#type' => 'tableselect',
'#empty' => $this->t('Your search for tech skills did not return '
. 'any results.'),
'#header' => [
'name' => $this->t('SKILL NAME'),
'description' => $this->t('DESCRIPTION'),
'status' => $this->t('STATUS'),
'changed' => $this->t('LAST UPDATED'),
'actions' => $this->t('ACTIONS')
],
'#options' => $this->getTableOptions(),
],
'tech_skills_pager' => [
'#theme' => 'pager',
],
];
return $form;
Most examples of paging I see use $build['pager'] rather than $form['pager']. I'm just wondering if pager isn't a form renderable element? Could that be the reason its not showing? Kinda lost on this. Any thoughts please?
Thanks