Skip to content

Commit

Permalink
hotfix: set temp default username value to avoid validation errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielwoodland committed Dec 11, 2023
1 parent 448cc22 commit 70d6763
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions web/modules/custom/nys_registration/src/Form/RegisterForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
namespace Drupal\nys_registration\Form;

use Drupal\Component\Datetime\TimeInterface;
use Drupal\Component\Utility\Random;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageManagerInterface;

use Drupal\file\Entity\File;
use Drupal\media\Entity\Media;
use Drupal\nys_registration\RegistrationHelper;
Expand Down Expand Up @@ -169,6 +171,10 @@ public function formBuildStep1(array &$form, FormStateInterface $form_state): ar
// The username will be auto-populated during creation.
$form['account']['name']['#access'] = FALSE;

// Set temp username value to avoid validation errors.
$random = new Random();
$form['account']['name']['#default_value'] = $random->name();

// These fields are not collected during registration.
$disable = [
'field_dateofbirth',
Expand Down

0 comments on commit 70d6763

Please sign in to comment.