public function addFormSucceeded(Form $form, ArrayHash $values): void
	{
		if ($values->generatePassword) {
			$password = Random::generate($this->minPasswordLength, $this->passwordChars);
		} else {
			$password = $values->password;
		}

		$user = new User;
		$this->orm->users->attach($user);
		try {
			$user->setUsername($values->username);
		} catch (UniqueConstraintViolationException $ex) {
			$form->addError('cms.user.duplicityUsername');
			return;
		} catch (InvalidArgumentException $ex) {
			$form->addError('cms.user.invalidUsername');
			return;
		}

		try {
			$user->setEmail($values->email);
		} catch (UniqueConstraintViolationException $ex) {
			$form->addError('cms.user.duplicityEmail');
			return;
		} catch (InvalidArgumentException $ex) {
			$form->addError('cms.user.invalidUsername');
			return;
		}

		try {
			$user->setPhone($values->phone ?: null);
		} catch (InvalidArgumentException $ex) {
			$form->addError('cms.user.invalidPhone');
			return;
		}

		$user->firstName = $values->firstName;
		$user->surname = $values->surname;

		$language = $this->localeService->getById($values->language);
		$user->language = $language === null ? null : $language->name;

		$user->roles->set($values->roles);
		$user->setPassword($password);

		$this->orm->persistAndFlush($user);

		if ($this->configurator->sendNewUserPassword) {
			$this->mailer->sendNewUser($user->email, $user->username, $password);
		}

		$this->flashNotifier->success('cms.user.dataSaved');
		$this->restoreBacklink();
	}