I figured it out, hopefully this will help someone else with a similar question.
Instead of doing a $formstate->setRebuild();
in the submitForm
method, I changed it to
$form_state->setRedirect(
'sliker_drupal_backend.browser',
[],
[
'query'=>[
'logic'=>$form_state->getValue('logic'),
'items'=>$form_state->getValue('items'),
'phrase'=>$form_state->getValue('phrase'),
'visibility'=>$form_state->getValue('visibility'),
'ids'=>$form_state->getValue('ids'),
],
]);
the setRedirect()
method takes three arguments:
- Route machine name
- Arguments (to fill in "placeholders" in the route path)
- Options which are any options that can be passed to a
\Drupal\Core\Url
By searching code, found options is an associative array and the keys can be any of:
- 'query': An array of query key/value-pairs (without any URL-encoding) to append to the URL.
- 'fragment': A fragment identifier (named anchor) to append to the URL. Do not include the leading '#' character.
- 'absolute': Defaults to FALSE. Whether to force the output to be an absolute link (beginning with http:). Useful for links that will be displayed outside the site, such as in an RSS feed.
- 'attributes': An associative array of HTML attributes that will be added to the anchor tag if you use the \Drupal\Core\Link class to make the link.
- 'language': An optional language object used to look up the alias for the URL. If $options['language'] is omitted, it defaults to the current language for the language type LanguageInterface::TYPE_URL.
- 'https': Whether this URL should point to a secure location. If not defined, the current scheme is used, so the user stays on HTTP or HTTPS respectively. TRUE enforces HTTPS and FALSE enforces HTTP.
I then updated my logic in the form build to look for query parameters and to use that information if it is present.
See https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Form!FormState.php/function/FormState%3A%3AsetRedirect/8.9.x for more information on setRedirect()
.