You are here

public static function EntityconnectFormUtils::childFormCancel in Entity connect 8.2

Sets the redirect to admin/entityconnect/redirect page.

Parameters

array $form: Child form.

\Drupal\Core\Form\FormStateInterface $form_state: Child form state.

File

src/EntityconnectFormUtils.php, line 398

Class

EntityconnectFormUtils
Contains form alter, callbacks and utility methods for entityconnect.

Namespace

Drupal\entityconnect

Code

public static function childFormCancel(array $form, FormStateInterface $form_state) {
  $triggeringElement = $form_state
    ->getTriggeringElement();
  $cache_id = $triggeringElement['#parent_build_cache_id'];
  if ($cache_id && \Drupal::getContainer()
    ->get('entityconnect.cache')
    ->get($cache_id)) {
    $form_state
      ->setRedirect('entityconnect.return', [
      'cache_id' => $cache_id,
      'cancel' => 1,
    ]);
  }
}