craftcms/guest-entries

Is there anyway to customize the 'action' route(s) ?

jesuismaxime opened this issue · 3 comments

I work on a sign-up process on a project that will need to create two entry (for 2 different sections) on the same "form" (I will handle this by ajax) and I want to avoid the use of guest-entries/save in my template to be more constant with my form process. Is there any way to use the builtin Craft routing to do that ?

Already try with something like this :

return [
    'app' => [
        'app/create/parent' => 'guest-entries/save',
        'app/create/child' => 'guest-entries/save',
    ],
];

...and that’s not working event if the official doc on the advanced routing let you believe that you can add a custom routing for a controller.

That should work in theory, yes, but you will need to reference the route in the request URI (e.g. POST https://example.com/app/create/parent, and also make sure you’re not passing an action param in the request body.

Where should I add the "route reference in the request URI" ?

I just mean that the URL you are making an Ajax request to should have a URI based on the route.