Performs redirect with search params appended to the uri.
In case of triggering element is edit-search-submit it redirects to current location with added query string containing submitted search form values.
array $form: Drupal form array.
FormStateInterface $form_state: Drupal form_state array.
$type: Entity type.
bool Returns TRUE, if redirect has been set.
public function overviewSearchFormRedirect(array $form, FormStateInterface $form_state, $type) {
if ($form_state
->getTriggeringElement()['#id'] == 'edit-search-cancel') {
$form_state
->setRedirect('tmgmt.source_overview', array(
'plugin' => $this->pluginId,
'item_type' => $type,
));
return TRUE;
}
elseif ($form_state
->getTriggeringElement()['#id'] == 'edit-search-submit') {
$query = array();
foreach ($form_state
->getValue('search') as $key => $value) {
$query[$key] = $value;
}
$form_state
->setRedirect('tmgmt.source_overview', array(
'plugin' => $this->pluginId,
'item_type' => $type,
), array(
'query' => $query,
));
return TRUE;
}
return FALSE;
}