You are here

public static function EntityconnectFormUtils::childFormDeleteSubmit in Entity connect 8.2

Sets delete button on child form.

On deletion submission of a child form we set: the form_state redirect with build cache id.

Parameters

array $form: Child form.

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

File

src/EntityconnectFormUtils.php, line 455

Class

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

Namespace

Drupal\entityconnect

Code

public static function childFormDeleteSubmit(array $form, FormStateInterface $form_state) {
  $triggering_element = $form_state
    ->getTriggeringElement();
  if (in_array('delete', $triggering_element['#parents'])) {
    $redirect = $form_state
      ->getRedirect();
    $query = $redirect
      ->getOption('query');
    if (!is_array($query)) {
      $query = [];
    }
    $redirect
      ->setOption('query', $query + [
      'build_cache_id' => $form_state
        ->getValue('parent_build_cache_id'),
      'child' => 1,
    ]);
  }
}