From 70d67636366fa1de0f175f64e1fd1e0aff2b462e Mon Sep 17 00:00:00 2001 From: Nathaniel Woodland Date: Mon, 11 Dec 2023 16:07:55 -0500 Subject: [PATCH] hotfix: set temp default username value to avoid validation errors. --- .../custom/nys_registration/src/Form/RegisterForm.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/modules/custom/nys_registration/src/Form/RegisterForm.php b/web/modules/custom/nys_registration/src/Form/RegisterForm.php index c0d010bab8..12e1319262 100644 --- a/web/modules/custom/nys_registration/src/Form/RegisterForm.php +++ b/web/modules/custom/nys_registration/src/Form/RegisterForm.php @@ -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; @@ -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',