You are here

public function UserBadgesListBuilder::submitForm in User Badges 8

Form submission handler.

Parameters

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

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

Overrides FormInterface::submitForm

File

src/Controller/UserBadgesListBuilder.php, line 154
Contains \Drupal\user_badges\Controller\UserBadgesListBuilder.

Class

UserBadgesListBuilder
Class UserBadgesListBuilder.

Namespace

Drupal\user_badges\Controller

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $badge_ids = array_keys($form_state
    ->getValue('badge'));

  /** @var \Drupal\user\Entity\User $user */
  $user = $this->user;
  $user
    ->set('field_user_badges', $badge_ids);
  $user
    ->save();
}