Search code examples
fluidextbasetypo3-9.x

TYPO3 error «action is not allowed by this plugin»


I'm trying to make an Ajax-call to my Controller.

I placed a hidden link in my form like this:

<f:link.action action="ajaxCheckEmailExistsFE" controller="Profiles" class="hidden" id="checkEmailExistsAjaxLink"></f:link.action>

In my Javascript, I extract the href from this link:

var target = $('#checkEmailExistsAjaxLink').attr('href');

And then send my request with jQuery's $.post method.

When the link is called, I get the infamous error

The action \"ajaxCheckEmailExistsFE\" (controller \"Profiles\") is not allowed by this plugin. Please check TYPO3\\CMS\\Extbase\\Utility\\ExtensionUtility::configurePlugin() in your ext_localconf.php

But the action is clearly set in ext_localconf.php!

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyVendor.MyExt',
    'MyPlugin',
    [
        'Profiles' => 'editFE, showFE, updateFE, ajaxCheckEmailExistsFE'
    ],
    // non-cacheable actions
    [
        'Profiles' => 'editFE, showFE, updateFE, ajaxCheckEmailExistsFE'
    ]
);

The same workflow works perfectly in BE-Mode.

I had the same problem with the updateFE-Action. When the form was submitted, I got the same error like above. I had to add it to the switchable-controller-actions in my flexform (-> <numIndex index="1">Profiles-&gt;editFE;Profiles-&gt;updateFE</numIndex>) - which is equally odd.

Why is this happening???

This is TYPO3 9.5

[Edit] For the time being, I ended up adding the action to the switchable-controller-actions just like I did for the updateFE-Action. This is VERY cumbersome, though, since I have to set the plugin-action on the page every time I add a new action. If anybody has a better solution, I'd be extremely thankful!


Solution

  • Indeed, this IS cumbersome, but it is also the only working way for switchable actions in TYPO3 extbase controllers. This check is intended to ensure that specific actions are only callable when you are in the "correct" plugin, as you may have several plugins inside one extension, which then may utilize different actions. So in the end, this feature prevents one plugin to call an action which should only be callable inside another plugin of the same extension. If you do not need the editor to switch action sets of your plugins though, you can remove this config part from your flexform, which will solve the need to edit this for new actions.

    As a famous example, take a look into the config of the news extension. There is one plugin which allows list+detail view, and different ones for just list or just detail view. So as an admin, you have to choice of structuring your website (routing and templates) for different news setups.

    Even in the TYPO3 community, there are voices to get rid of this feature, so maybe it will be solved in future versions.