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
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | ik_modals-3.0.4_too_few_arguments_ContentEntityForm.patch | 4.05 KB | rosemaryreilman |
Issue fork ik_modals-3219630
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:
- 3219630-argumentcounterror-too-few
changes, plain diff MR !1
Comments
Comment #4
mohit.bansal623 commentedMR created, uploading the patch.
Please review.
Comment #5
joelseguinThe 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.
Comment #6
mohit.bansal623 commentedIf this issue is fixed, we can consider as fixed and close.
Comment #7
rosemaryreilmanThanks for reporting @joelseguin and @mohit.bansal623 for quick patch. I'll review this week and hopefully merge into the project!
Comment #8
larisse commentedThe patch #4 works perfectly to me.
Changing to RTBC.
Comment #9
larisse commentedComment #10
rosemaryreilmanComment #11
rosemaryreilmanThanks 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 requirementComment #13
rosemaryreilmanPatch applied to v. 3.0.5.
Comment #15
rosemaryreilman