You are here

public function Keycloak::deleteRuleSubmit in Keycloak OpenID Connect 8

Submit function for the 'Delete rule' ajax callback.

Removes a rule from the user group mapping rules table.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Plugin/OpenIDConnectClient/Keycloak.php, line 479

Class

Keycloak
OpenID Connect client for Keycloak.

Namespace

Drupal\keycloak\Plugin\OpenIDConnectClient

Code

public function deleteRuleSubmit(array &$form, FormStateInterface $form_state) {
  $target_id = $form_state
    ->getTriggeringElement()['#attributes']['data-delete-target'];

  // Remove the row from form.
  $rules = $form_state
    ->get('rules');
  $rules = array_diff($rules, [
    $target_id,
  ]);
  $form_state
    ->set('rules', $rules);

  // Rebuild the form.
  $form_state
    ->setRebuild();
}