Argument 1 passed to _campaignmonitor_registration_option_descriptions() must be an instance of Drupal\Core\Render\Element, array given

Created on 15 July 2022, almost 3 years ago
Updated 28 April 2023, almost 2 years ago

Problem/Motivation

I'm using the submodule campaignmonitor_registration to allow users to subscribe to lists on user registration and I'm getting the following error:

TypeError: Argument 1 passed to _campaignmonitor_registration_option_descriptions() must be an instance of Drupal\Core\Render\Element, array given in _campaignmonitor_registration_option_descriptions() (line 136 of modules/contrib/campaignmonitor/modules/campaignmonitor_registration/campaignmonitor_registration.module).
_campaignmonitor_registration_option_descriptions(Array, Object)
call_user_func_array('_campaignmonitor_registration_option_descriptions', Array) (Line: 1078)
Drupal\Core\Form\FormBuilder->doBuildForm('user_register_form', Array, Object) (Line: 1070)
Drupal\Core\Form\FormBuilder->doBuildForm('user_register_form', Array, Object) (Line: 574)
Drupal\Core\Form\FormBuilder->processForm('user_register_form', Array, Object) (Line: 320)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)

Seems that the issue was introduced on Fix code standards when the parameter type was added as Drupal\Core\Render\Element instead of an array. Switching to an array fixes the issue for me.

While trying to get it to work I've also realized that the checkbox for the user to opt-in was showing as an extra checkbox with the CM lists and not toggling the options when I had "User selects list(s)" as the subscription type so this needs to be fixed as well.

Steps to reproduce

  • Install campaignmonitor_registration submodule.
  • On /admin/config/services/campaignmonitor/registration select "User selects list(s)" as subscription type.
  • Edit 2 lists and enable the option "Display list on registration page".
  • Visit registration page.

Proposed resolution

Switch _campaignmonitor_registration_option_descriptions first parameter to use array type.
Regarding the registration text showing as an extra checkbox I think we should have the option to display the Registration Text as opt-in or just as title because:

  1. It was not triggering visibility when "User selects list(s)" was enable.
  2. You may want a title instead of an opt-in option.

For now, I've just added visibility states if that field was filled and fixed label/help text to make the current functionality more clear.

🐛 Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

🇨🇦Canada bbombachini London, ON

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024