The "" plugin does not exist on config save in PolicyEditForm.php

Created on 1 November 2023, about 1 year ago

Problem/Motivation

Drupal\Component\Plugin\Exception\PluginNotFoundException thrown in Drupal\ Core \Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php when saving configuration in PolicyEditForm

The full error:

An unexpected error has occurred. Please try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException : The "" plugin does not exist. Valid plugin IDs for Drupal\symfony_mailer\Processor\EmailAdjusterManager are: email_plain, email_cc, email_priority, mailer_url_to_absolute, mailer_wrap_and_convert, email_to, email_subject, mailer_default_headers, email_bcc, mailer_hooks, email_body, email_from, email_theme, email_transport, mailer_inline_css, email_skip_sending, email_reply_to in Drupal\ Core \Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php ).
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('', Array) (Line: 17)
Drupal\symfony_mailer\Processor\AdjusterPluginCollection->initializePlugin('') (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get('') (Line: 160)
Drupal\Core\Plugin\DefaultLazyPluginCollection->setInstanceConfiguration('', Array) (Line: 135)
Drupal\Core\Plugin\DefaultLazyPluginCollection->setConfiguration(Array) (Line: 26)
Drupal\symfony_mailer\Form\PolicyEditForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('mailer_policy_edit_form', Object) (Line: 375)
Drupal\Core\Form\FormBuilder->rebuildForm('mailer_policy_edit_form', Object, Array) (Line: 633)
Drupal\Core\Form\FormBuilder->processForm('mailer_policy_edit_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 44)
Drupal\redirect_after_login\RedirectMiddleware->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

  1. Go to /admin/config/system/mailer and add a new Policy, After selecting Type and adding Sub-Type it will redirect to Policy edit form.
  2. Select any element and press "Add Element".
  3. Add element details and press Save on the form.

Please see the video https://drive.google.com/file/d/1qHwrg8Kub8tGWLzb_3y2DPXHBBv9b_-6/view?usp=sharing.

Proposed resolution

I guess that the #empty_value is causing that error since it is producing empty value for configs (but I am not sure, needs to be verified).

$form['add_actions']['add_select'] = [
  '#type' => 'select',
  '#options' => $options,
  '#empty_value' => '',
  '#empty_option' => $this->t('- Select element to add -'),
];
🐛 Bug report
Status

Needs work

Version

1.4

Component

Code

Created by

🇦🇲Armenia alen simonyan

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

Merge Requests

Comments & Activities

  • Issue created by @alen simonyan
  • Status changed to Postponed: needs info about 1 year ago
  • 🇬🇧United Kingdom adamps

    It works for me and no one else has reported. Maybe it is related to something on your site? I suggest to test with creating policy for one of the Core modules.

  • 🇦🇲Armenia alen simonyan

    Hi Adam,
    I also tried with one of the core modules and it behaves the same

    https://drive.google.com/file/d/1X7qqCv8DMaqXBZTSUGuKdzdOqpFZPy49/view?usp=sharing

  • 🇺🇸United States scotthreha

    I just completed a Drupal 10 upgrade and I'm getting this same error when I try to add a new element to an existing policy. It worked without problems during the entire development process, but now that I've pushed the upgrade to production it fails.

    Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for Drupal\symfony_mailer\Processor\EmailAdjusterManager are: mailer_url_to_absolute, email_bcc, email_body, email_cc, mailer_default_headers, email_from, mailer_hooks, mailer_inline_css, email_plain, email_priority, email_reply_to, email_skip_sending, email_subject, email_theme, email_to, email_transport, mailer_wrap_and_convert in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /var/www/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

    I should add that this is a policy for email receipts in Drupal Commerce.

  • 🇷🇴Romania andreic

    The problem was competing form actions. There was $form['add_actions'] as type 'action' and then $form['actions'] as type 'action.
    The $name variable was always empty (attached screenshot) when clicking the Save button, hence the error in this issue.
    The solution was to make $form['add_actions'] a container within the existing $form['actions'].
    Patch added.

  • 🇬🇧United Kingdom adamps

    Thanks. Drupal.org now uses requests instead of patches please.

  • 🇬🇧United Kingdom adamps

    Please put your changes in the 3398364-the--plugin branch then create a merge request. This will cause the tests to run. Thanks.

  • First commit to issue fork.
  • Merge request !103Issue#3498364:plugin-not-exit. → (Open) created by Unnamed author
  • 🇮🇳India atul_ghate

    I have changed patch into the MR, please review.

  • Pipeline finished with Success
    about 2 months ago
    Total: 155s
    #293282
  • 🇬🇧United Kingdom adamps

    Thanks. For me the result is worse than before. Before the select and button were on the same line, and now they are one below the other - see screenshots attached.

    I believe that the buttons are no longer in the container because they still have $form['add_actions']. Instead it worked for me like this:

        $form['add_actions'] = [
          '#type' => 'container',
          '#weight' => -1,
          '#attributes' => ['class' => ['container-inline']],
        ];
    
    

    Please can you check if that still works for you, then update the MR?

  • 🇷🇴Romania andreic

    I can confirm the above in #13 works fine!

Production build 0.71.5 2024