Skip to content

ControlPanel/Routes are not dispatched for fieldtype-only add-ons #5412

Open

Description

@jcogs-design

Description of the problem
ExpressionEngine 7 recognises modern ControlPanel/Routes classes for a module add-on, but not for an add-on installed only as a fieldtype. A CP request to a valid route returns a 404 before the route class can be instantiated.

  • ExpressionEngine 7
  • PHP 8.2
  • Fieldtype-only add-on using PSR-4 autoloading
  • Route class extending ExpressionEngine\Service\Addon\Controllers\Mcp\AbstractRoute
    Minimal add-on structure

Minimal add-on structure

my_fieldtype/
  addon.json
  addon.setup.php
  ft.my_fieldtype.php
  mcp.my_fieldtype.php
  ControlPanel/
    Routes/
      PreviewData.php

PreviewData.php:

namespace Vendor\MyFieldtype\ControlPanel\Routes;

use ExpressionEngine\Service\Addon\Controllers\Mcp\AbstractRoute;

class PreviewData extends AbstractRoute
{
    protected $route_path = 'preview_data';

    public function process($id = false)
    {
        ee()->output->send_ajax_response(['success' => true]);

        return $this;
    }
}

How to reproduce

  1. Install suitable add-on as a fieldtype, without installing a module component.

  2. Load a CP page that includes an AJAX request to:

    admin.php?/cp/addons/settings/my_fieldtype/preview_data
    
  3. Send a POST request to that URL.

Expected result

EE resolves preview_data to:

Vendor\MyFieldtype\ControlPanel\Routes\PreviewData

and executes process().

Actual result

EE returns its standard 404: Item does not exist page. The route class is never reached, despite being autoloadable and extending the documented MCP AbstractRoute base class.

Suspected cause identified in core dispatch

ExpressionEngine\Controller\Addons\Addons::settings() dispatches by installed component type:

  1. Module add-ons use getModuleSettings().
  2. Fieldtype-only add-ons use getFieldtypeSettings().
  3. Extensions use their own settings handler.

getModuleSettings() delegates unknown methods to ExpressionEngine\Service\Addon\Mcp, which resolves modern ControlPanel/Routes classes. The Fieldtype branch does not make that delegation; it renders fieldtype settings instead. Consequently, the route segment (preview_data) is discarded and the request cannot reach PreviewData.

Workaround

Use an ACT endpoint (?ACT=<action_id>) for fieldtype AJAX requests. This avoids the CP route dispatcher, but can be unsuitable for CP workflows where ACT traffic is throttled or blocked separately from CP requests.

Requested behaviour

Please make modern ControlPanel/Routes dispatch available to installed fieldtype-only add-ons, preferably by attempting MCP route resolution before falling back to the component-specific settings handler. This would make the documented ControlPanel/Routes convention work consistently for module, fieldtype, and extension add-ons.

At minimum, please document that CP routes are supported only for module add-ons if that limitation is intentional.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions