RegistrantListBuilder->getCustomFields() does not get custom fields from registrant types

Created on 7 February 2024, 5 months ago
Updated 26 February 2024, 4 months ago

Problem/Motivation

When using the standard list of registrants created via RegistrantListBuilder, the getCustomFields() method does not actually return the custom fields.

The returned $fields array looks only like this. A field with name field_first_name added to the Default registrant type does not appear, for example.

array:19 [▼
  "id" => Drupal\Core\Field\BaseFieldDefinition {#2272 ▶}
  "uuid" => Drupal\Core\Field\BaseFieldDefinition {#2275 ▶}
  "revision_id" => Drupal\Core\Field\BaseFieldDefinition {#2279 ▶}
  "bundle" => Drupal\Core\Field\BaseFieldDefinition {#2282 ▶}
  "revision_created" => Drupal\Core\Field\BaseFieldDefinition {#2286 ▶}
  "revision_user" => Drupal\Core\Field\BaseFieldDefinition {#2290 ▶}
  "revision_log_message" => Drupal\Core\Field\BaseFieldDefinition {#2294 ▶}
  "status" => Drupal\Core\Field\BaseFieldDefinition {#2298 ▶}
  "user_id" => Drupal\Core\Field\BaseFieldDefinition {#2304 ▶}
  "email" => Drupal\Core\Field\BaseFieldDefinition {#2308 ▶}
  "eventseries_id" => Drupal\Core\Field\BaseFieldDefinition {#2312 ▶}
  "eventinstance_id" => Drupal\Core\Field\BaseFieldDefinition {#2316 ▶}
  "waitlist" => Drupal\Core\Field\BaseFieldDefinition {#2320 ▶}
  "type" => Drupal\Core\Field\BaseFieldDefinition {#2326 ▶}
  "created" => Drupal\Core\Field\BaseFieldDefinition {#2330 ▶}
  "changed" => Drupal\Core\Field\BaseFieldDefinition {#2334 ▶}
  "title" => Drupal\Core\Field\BaseFieldDefinition {#2338 ▶}
  "revision_default" => Drupal\Core\Field\BaseFieldDefinition {#2341 ▶}
  "metatag" => Drupal\Core\Field\BaseFieldDefinition {#2347 ▶}

Steps to reproduce

Add a custom field to a Registrant type. Go to a list of registrants for an event instance with route /events/{eventinstance}/registrations and the custom field does not appear.

Proposed resolution

Refactor getCustomFields() method to search within relevent Registrant type to get custom fields.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Recurring Events Registration (Submodule)

Created by

🇨🇦Canada endless_wander

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @endless_wander
  • Status changed to Needs review 5 months ago
  • 🇨🇦Canada endless_wander

    Adding a patch that uses the real bundle name for the Registrant type, which for my site is "default." RegistrantListBuilder->getCustomFIelds() will now use all the fields attached to this bundle and the resulting list looks as expected with all custom fields.

    Is there actually a way to add different Registrant bundles? /admin/structure/events/registrant/types/add goes nowhere and there is no route for adding Registrant types. (In fact, only EventSeries have such a route for adding new types. Was this a recent change?). Is "default" the only possible bundle name for Registrants, then? Is it thus okay to hardcode "default" as the bundle name within RegistrantListBuilder?

    I tried out a clean install on simplytest.me and "default" is the bundle name created when installing the recurring_events_registration submodule.

    I would prefer to use Recurring Events Views to power the Registrant lists, but it is not compatible with Series Registration at this time. I have been untangling this today and will post another issue related to that.

    For now, I believe it is important that the getCustomFields() method returns custom fields as expected and so I believe this patch will be a fix.

  • 🇺🇸United States owenbush Denver, CO

    Thanks for raising this issue and providing a patch. I'll get that merged shortly.

    To answer your question about creating a Registrant type, you cannot create one directly, just like you cannot create an Event Instance type directly. If you create a new Event Series type, it will also create an equivalent (same name) Event Instance type and Registrant type. The idea is that if you create an Event Series type, then the Instance and Registrant types will match.

    An example, if you created a 'Youth' event series type with a number of instances, those instances would be of type 'Youth' too. And any registrants for a 'Youth' series or instance will also be of type 'Youth'. This allows for creating different registration experiences and forms per type.

    • owenbush committed 4c2f09e2 on 2.0.x
      Issue #3419667 by endless_wander, owenbush: RegistrantListBuilder->...
  • Status changed to Fixed 5 months ago
  • 🇺🇸United States owenbush Denver, CO

    This has been merged into 2.0.x and will be part of the next tag release.

  • 🇨🇦Canada endless_wander

    Awesome, thanks @owenbush

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024