From 6098f176252186b45f466b933bcb8ac8e5aa82d6 Mon Sep 17 00:00:00 2001
From: owenbush <ojb@ukhhf.co.uk>
Date: Wed, 5 Aug 2020 10:36:19 -0600
Subject: [PATCH] Fix issue with editing an old registrant and form fields
 being hidden

---
 .../src/Form/RegistrantForm.php                             | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/modules/recurring_events_registration/src/Form/RegistrantForm.php b/modules/recurring_events_registration/src/Form/RegistrantForm.php
index ae71fb67..bc6f2181 100644
--- a/modules/recurring_events_registration/src/Form/RegistrantForm.php
+++ b/modules/recurring_events_registration/src/Form/RegistrantForm.php
@@ -301,6 +301,10 @@ class RegistrantForm extends ContentEntityForm {
    *   The form state interface.
    */
   protected function hideFormFields(array &$form, FormStateInterface $form_state) {
+    /* @var $entity \Drupal\recurring_events_registration\Entity\Registrant */
+    $entity = $this->entity;
+    $new = $entity->isNew();
+
     $form_fields = $this->fieldManager->getFieldDefinitions('registrant', $this->entity->getBundle());
 
     $availability = $this->creationService->retrieveAvailability();
@@ -311,7 +315,7 @@ class RegistrantForm extends ContentEntityForm {
     // no spaces left, and no waitlist.
     if (($availability === 0 && !$waitlist) || !$registration_open) {
       foreach ($form_fields as $field_name => $field) {
-        if (isset($form[$field_name])) {
+        if (isset($form[$field_name]) && $new) {
           $form[$field_name]['#printed'] = TRUE;
         }
       }
-- 
GitLab