You are here

private function RiddlerSettingsForm::removeFormStateValue in Captcha Riddler 8

Remove the riddle row from $form_state->values and $form_state->input.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state:

1 call to RiddlerSettingsForm::removeFormStateValue()
RiddlerSettingsForm::removeSubmit in src/Form/RiddlerSettingsForm.php
Submit function for remove a riddle button.

File

src/Form/RiddlerSettingsForm.php, line 235

Class

RiddlerSettingsForm
Displays the Riddler settings form.

Namespace

Drupal\riddler\Form

Code

private function removeFormStateValue(FormStateInterface $form_state) {
  $trigger = $form_state
    ->getTriggeringElement();
  $row = str_replace('riddle', '', $trigger['#id']);
  $values = $form_state
    ->getValues();
  unset($values['riddler'][$row]);
  $values['riddler'] = array_values($values['riddler']);
  $form_state
    ->setValue('riddler', $values['riddler']);
  $form_state
    ->setUserInput($values);
}