Problem/Motivation

I cannot seem to add modal content under a fresh install of a Drupal 9 site.

Steps to reproduce

Install a fresh copy of Drupal 9 and install the module. Add the "Modals Block" to a block region. Add a new modal by going directly to /admin/content/modal (didn't seem to be available from the Drupal UI under the "Content" section).

The error will be thrown as the form for creating content of the default modal type attempts to load.

Here is a copy of the error from the event log:

ArgumentCountError: Too few arguments to function Drupal\Core\Entity\ContentEntityForm::__construct(), 1 passed in /var/www/html/web/modules/contrib/ik_modals/src/Form/ModalForm.php on line 43 and exactly 3 expected in Drupal\Core\Entity\ContentEntityForm->__construct() (line 56 of /var/www/html/web/core/lib/Drupal/Core/Entity/ContentEntityForm.php)
#0 /var/www/html/web/modules/contrib/ik_modals/src/Form/ModalForm.php(43): Drupal\Core\Entity\ContentEntityForm->__construct(Object(Drupal\Core\Entity\EntityRepository))
#1 /var/www/html/web/modules/contrib/ik_modals/src/Form/ModalForm.php(58): Drupal\ik_modals\Form\ModalForm->__construct(Object(Drupal\Core\Entity\EntityRepository), Object(Drupal\Core\Session\AccountProxy), Object(Drupal\Core\Messenger\Messenger))
#2 /var/www/html/web/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php(28): Drupal\ik_modals\Form\ModalForm::create(Object(Drupal\Core\DependencyInjection\Container))
#3 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php(214): Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition('Drupal\\ik_modal...')
#4 /var/www/html/web/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php(69): Drupal\Core\Entity\EntityTypeManager->getFormObject('modal', 'add')
#5 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(58): Drupal\Core\Entity\HtmlEntityFormController->getFormObject(Object(Drupal\Core\Routing\RouteMatch), 'modal.add.defau...')
#6 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#7 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#8 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(578): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#10 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#11 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#13 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(716): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#22 {main}

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork ik_modals-3219630

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

joelseguin created an issue. See original summary.

mohit.bansal623 made their first commit to this issue’s fork.

mohit.bansal623’s picture

Status: Active » Needs review
StatusFileSize
new2.8 KB

MR created, uploading the patch.
Please review.

joelseguin’s picture

The patch seems to have done the trick. I was able to add modal content without issues.

I'm now noticing a javascript error as an anonymous user, but I will investigate more and create another issue for that.

mohit.bansal623’s picture

If this issue is fixed, we can consider as fixed and close.

rosemaryreilman’s picture

Thanks for reporting @joelseguin and @mohit.bansal623 for quick patch. I'll review this week and hopefully merge into the project!

larisse’s picture

StatusFileSize
new45.26 KB
new5.56 KB

The patch #4 works perfectly to me.
Changing to RTBC.

larisse’s picture

Status: Needs review » Reviewed & tested by the community
rosemaryreilman’s picture

Assigned: Unassigned » rosemaryreilman
rosemaryreilman’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
StatusFileSize
new4.05 KB

Thanks everyone for your help on this! @mohit.bansal623 I'm adding another patch that keeps the messenger interface via services injection instead of calling \Drupal::service. Otherwise I think this is good to go. I need to test with latest D8 though to make sure I don't need to bump the core requirement

rosemaryreilman’s picture

Status: Patch (to be ported) » Fixed

Patch applied to v. 3.0.5.

rosemaryreilman’s picture

Status: Fixed » Closed (fixed)