public function SourcePluginUiBase::overviewSearchFormRedirect

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.

Parameters

array $form: Drupal form array.

FormStateInterface $form_state: Drupal form_state array.

$type: Entity type.

Return value

bool Returns TRUE, if redirect has been set.

1 call to SourcePluginUiBase::overviewSearchFormRedirect()
SourcePluginUiBase::overviewFormSubmit in src/SourcePluginUiBase.php
Submit handler for the source entities overview form.

File

src/SourcePluginUiBase.php, line 265

Class

SourcePluginUiBase
Default ui controller class for source plugin.

Namespace

Drupal\tmgmt

Code

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;
}