Problem/Motivation

On the event register form (for example node/1/register), the button "Create new Registrant" seems to do nothing and logs the following error:

TypeError: Argument 3 passed to Drupal\rng\Form\RegistrantFields::__construct() must implement interface Drupal\rng\Entity\RegistrantInterface or be null, array given, called in /Users/youri/Websites/drupal/drupalsites/drupal8/web/modules/wip/rng/src/Element/Registrants.php on line 151 in Drupal\rng\Form\RegistrantFields->__construct() (line 55 of /rng/src/Form/RegistrantFields.php)

This is how the register form looks like at the time of writing:

A logged in user can register theirselves when clicking "Myself" and then hit "Save", but there is no way to add other users as registrant or for anonymous users to register as "Contact" (using the rng_contact module).

Steps to reproduce

  1. Install the RNG module.
  2. Add an event type (choose for example to link it to a content type).
  3. Add a registration type.
  4. Create an event node (or an instance of an other content entity type that represents the event).
  5. Enable "Accept new registrations" on the Event tab and enable the created registration type (and click "Save").
  6. Go the "Register" tab that now appeared.
  7. Click the button "Create new Registrant".

Nothing happens and an error gets logged.

Proposed resolution

Perhaps completely rebuild the registration UI from scratch. Maybe something like this:


Remaining tasks

User interface changes

Yes, probably.

API changes

Data model changes

Original report by MartinMa

Setting up event type seems to work

If I want to register to an event I get unespected error with following message in dblog:

Error: Cannot use object of type Drupal\Core\Entity\EntityTypeBundleInfo as array in Drupal\rng\Element\Registrants::processIdentityElement() (Line 182 in /modules/contrib/rng/src/Element/Registrants.php)

Issue fork rng-3114193

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

MartinMa created an issue. See original summary.

dhirendra.mishra’s picture

Status: Needs work » Needs review
StatusFileSize
new653 bytes

Here is the patch to above mentioned bug fix.

behindthepage’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that this patch fixes this problem.

dhirendra.mishra’s picture

Can we commit this then ?

alternativo’s picture

Using D8.8.3
Put patch#1 and solve problem on seeing register tab,
(I think it will be the same for line 623, same code problem)

but when saving registration, this error occurs:
Error: Call to undefined method Drupal\rng\EventMeta::getCapacity() in Drupal\rng\EventSubscriber\RegistrationWaitListSubscriber->onRegistrationInsert() (line 64...

Solved changing 'getCapacity()' - does not exist - with 'getRegistrationCapacity()'

Hope it helps

freelock’s picture

Status: Reviewed & tested by the community » Closed (outdated)

Hi,

Thank you for the patch! I think the issue is fixed through a bunch of other work I had on a local branch -- including some refactoring of the various capacity methods. I'm not sure that's entirely done, but this is no longer an issue...

Cheers,
John

mandclu’s picture

Version: 8.x-2.x-dev » 3.0.0-alpha1
Status: Closed (outdated) » Needs work

I can confirm that I'm seeing the originally reported error using RNG 3.0.0-alpha1 with Drupal 8.9.1 with a content type as the Event Type in RNG.

The patch does allow the "Register" tab to render properly, but as reported in #5 trying to save your registration throws the additional error:

Error: Call to undefined method Drupal\rng\EventMeta::getCapacity() in Drupal\rng\EventSubscriber\RegistrationWaitListSubscriber->onRegistrationInsert() (line 64 of /Users/martin/Sites/drupal_qa/web/modules/contrib/rng/src/EventSubscriber/RegistrationWaitlistSubscriber.php)

The fix described in #5 also still works.

Even with this patch applied I see a notice when the Register tab renders:

Notice: Undefined property: Drupal\Core\Entity\EntityTypeBundleInfo::$label in Drupal\rng\Element\Registrants::processIdentityElement() (line 182 of /Users/martin/Sites/drupal_qa/web/modules/contrib/rng/src/Element/Registrants.php)

Also, if I click "Create new" under "New Registrant" the spinner shows briefly and then nothing happens. In the error log I see the notice above again, as well as:

TypeError: Argument 3 passed to Drupal\rng\Form\RegistrantFields::__construct() must implement interface Drupal\rng\Entity\RegistrantInterface or be null, array given, called in /Users/martin/Sites/drupal_qa/web/modules/contrib/rng/src/Element/Registrants.php on line 150 in Drupal\rng\Form\RegistrantFields->__construct() (line 39 of /Users/martin/Sites/drupal_qa/web/modules/contrib/rng/src/Form/RegistrantFields.php)

mandclu’s picture

After some additional testing, I think (on 3.0.0-alpha1 at least) the patch only changes the error from a fatal error into a notice, but doesn't actually fix the intended behaviour.

$bundle_info is an instance of Drupal\Core\Entity\EntityTypeBundleInfo, so it can be used to load an array of labels for a particular entity type. I'm very new to RNG so I don't entirely follow what's meant to be used here, but I suspect it should actually be leveraging something further down, in a different conditional branch:

        /** @var \Drupal\rng\RegistrantFactoryInterface $registrant_factory */
        $registrant_factory = \Drupal::service('rng.registrant_factory');
        $new_person = $registrant_factory->createRegistrant([
          'event' => $event,
        ]);
        $new_person
          ->setRegistration($registration);
        $display = $entity_display_repository->getFormDisplay('registrant', $new_person->bundle());
        $display->buildForm($new_person, $person_subform['new_person']['newentityform'], $form_state);

Is the "Create new" button meant to show the label from $new_person->bundle()?

BigEd’s picture

I have just landed on this as well, without a fix in its current state this module is unusable, can we get to the bottom of this to get it working?

@freelock can you shed some light on this for the local branch you have been working on, I don't have enough exposure to the code to be able to give much help but willing to look at the code to help move this along.

freelock’s picture

Hi,

Sorry, I've got a long backlog of things in progress right now. We do have this working on a site right now, but there are a bunch of changes to the underlying code, and a couple areas with some specific hard-coded items that will need to get refactored some. I'll sort out the commits and push some working code to the dev branch in the next couple days...

I closed this as "Outdated" because the code throwing the error is no longer used at all.

Cheers,
John

webcultist’s picture

@freelock You have a great looking module here, didn't work with it right now, but looks quite good already.

My customer wants a solution in the next two weeks for a registration for an upcoming event.
I know, you owe nobody anything or so and I'm very thankful for the work you are doing here!
Do you think it will be possible to use this module in version 3 in the next two weeks for a new event registration or should I better use the 1.x branch? Would be also willing to test new patches & branches - not sure I can provide much help on code side.

Greetings

freelock’s picture

Status: Needs work » Fixed

Pushed up the code we've been working with, which does allow registrations.

  • freelock committed ab2294f on 3.x
    Issue #3114193 by dhirendra.mishra, freelock: cant register to an event
    

Status: Fixed » Closed (fixed)

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

ac’s picture

This is still an issue in dev, should be reopened.

rjp2u’s picture

Can confirm that this is still an issue on the latest dev

danstorm’s picture

Can confirm the original issue is still present on 3.0.0-alpha1 and 3.x-dev.

Can also confirm everything that is mentioned in #5 and #7 is present on both branches.

@freelock You mention in number 12 that the code you released is working on a site. Is one of the extra modules (e.g., rng_conflict, rng_date_scheduler) installed on that site and masking this issue there? I have nothing to back up that idea, it's just a thought :)

rogerb’s picture

Just confirming that the error described by #7 is still present in 3.x-dev.

TypeError: Argument 3 passed to Drupal\rng\Form\RegistrantFields::__construct() must implement interface Drupal\rng\Entity\RegistrantInterface or be null, array given, called in /app/modules/contrib/rng/src/Element/Registrants.php on line 150 in Drupal\rng\Form\RegistrantFields->__construct() (line 39 of /app/modules/contrib/rng/src/Form/RegistrantFields.php)

A great pity that this project is not progressing.

megachriz’s picture

Status: Closed (fixed) » Needs work

@RogerB
Good news! I recently got added as a maintainer to this project and I'm trying to get it into a working state again. I noticed that registering doesn't work for me either, but I couldn't find a quick way to fix it yet. I'm thinking of refactoring the code in src/Element/Registrants.php a bit. I hope my client gives me enough time to look into this. This project blocks a site from upgrading it to D9 for me.

But first, I'm bug hunting on the API level, so I get more familiar with the code.

megachriz’s picture

Title: cant register to an event » Can't add new registrants when registering for an event
Priority: Normal » Critical

I had a poke at this yesterday. I splitted the code from \Drupal\rng\Element\Registrants::processIdentityElement() into multiple methods to make the code look less bloated. I saw something that I believed to be a bug, namely that $element['people'][]['registrant'] had the same #parents value as $element['people'][]. Fixing that did resolve the error reported in #18, but it still did not make adding new registrants working.

So as of now, I see no quick way to fix this issue. I'm thinking it would be better to rebuild the registration UI from scratch. I wasn't fan of how the UI looked like anyway.

But I think I won't get the time from my client to rebuild this registration UI, especially since we already use our own customized registration UI.

megachriz’s picture

The patch is no longer relevant, so hiding that one.

megachriz’s picture

Issue summary: View changes
StatusFileSize
new171.16 KB
new97.14 KB
new122.13 KB

I updated the issue summary.

mandclu’s picture

@MegaChriz the Ticket module had a pretty slick UI but the D8 port seems to have stalled. If you're planning to rebuild the registration interface here, maybe draw some inspiration (or even some code?) from what had been implemented there?