I built a drop-down ajax pager that replaces a tableselect with the requested page of rows. The array of selected item IDs is stored in a hidden field and that logic is working across entity load/save and AJAX replacements.
When the form initially loads, my tableselect #default_value operates correctly and checks the selected rows on the first page. But after AJAX paging through the big list to a different page and back, the checkboxes aren't checked again.
I think this has to do with #default_value only working before the form has been submitted. How can I reset the state so that my updated tableselect #default_value is used after AJAX?
Just before the tableselect's array in the form builder function, put the following code:
For those ones experiencing the same case in Drupal 8, this is the equivalent solution:
$user_input = $form_state->getUserInput(); unset($user_input['my_tableselect']); $form_state->setUserInput($user_input);