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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3419667--addingCustomFieldsRegistrantList--2.patch | 2.48 KB | chrisla |
Comments
Comment #2
chrisla commentedAdding 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/addgoes 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.
Comment #3
owenbush commentedThanks 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.
Comment #5
owenbush commentedThis has been merged into 2.0.x and will be part of the next tag release.
Comment #6
chrisla commentedAwesome, thanks @owenbush