Project

General

Profile

Actions

Bug #102505

open

wrong routing after succesful call of an action in extbase-controller (with example-Extension)

Added by Dieter Dr. Porth 7 months ago. Updated 5 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2023-11-24
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I have a form, which contains more than one pages. The user should be allowed to bookmark every page of the form, so that he can finish his work at the next day. TYPO3 did not produce the correct link in the browser-adressline.

Reproduce the unexpected routing
1. Install Extension (plus TYPO3 11 and plus your own sitepackage i.e. with composer as `"monsun/bugtest": "^1.0"`
2. Define routing in site-Config (see fragment in /bugtest/SiteConfig/sites/bugtest/config.yaml)
3. Update models in Database
4. Add Plugin “bugtest_routingtest” on testpage
5. Open Testpage in the frontend.
6. Create a new Testmodel.
7. Use the edit-Link in the list-view.
8. Press the button ‘update and go to EditTwo-view/action’ in the edit-view
After doing step 8 you will arrive the editTwo-View. The browser will show an unreadable link in its adressline. The link looks something like this `https://mypage.ddev.site/testrouting?tx_bugtest_routingtest%5Baction%5D=update&tx_bugtest_routingtest%5Bcontroller%5D=Testmodel&cHash=caf03268fea2493bc9302787200df133`
I expected a link, which looks something like 'this https://mypage.ddev.site/testrouting/bugedittwo/1?cHash=dbe3b40227268c9b4619ce5c12e03ebe'.
(TYPO3 cann prdouce this link `https://one-job.ddev.site/testrouting/bugedittwo/1?cHash=dbe3b40227268c9b4619ce5c12e03ebe` expected for EditTwo-Action. See the generated link in the plugin-template.)

The automatically generated link shows, that the site-configuration seems to work correctly. The routing generation in the rendering-process of the plugin seems to be wrong.

Remark: If you remove the `action=”update”` in the <f:form> in `Edit.html` and/or `EditTwo.html`, TYPO3 will produce a link something like the following `https://one-job.ddev.site/testrouting/list`, which is not really helpful.


Files

bugtest.tar.gz (11.2 KB) bugtest.tar.gz Dieter Dr. Porth, 2023-11-24 10:19
bugtest.zip (29.8 KB) bugtest.zip Dieter Dr. Porth, 2024-01-19 11:49
Actions #1

Updated by Stefan Bürk 5 months ago · Edited

The routes are not really correct in the example extension
site configuration. Therefore, I advise you to read the
documentation regarding the routing and the extbase route
type and the required options [1].

All of the routes are missing a aspect mapping for the
argument `model` to a extbase table and slug field. Without
it it won't work. On top of that, your model is missing a
slug field. So you should add that first in the `ext_tables.sql`
and as a `tca field` - for example a `path_segment` field [2].

Than, your site configuration routing should be look like
following:

routeEnhancers:
  testbug:
    type: Extbase
    limitToPages:
      - 74
    extension: Bugtest
    plugin: routingtest
    routes:
      -
        routePath: '/list/'
        _controller: 'Testmodel::list'
      -
        routePath: '/bugedit/{model}'
        _controller: 'Testmodel::edit'
        _arguments:
          model: testmodel
      -
        routePath: '/bugedittwo/{model}'
        _controller: 'Testmodel::editTwo'
        _arguments:
          model: testmodel
      -
        routePath: '/bugupdate/{model}'
        _controller: 'Testmodel::update'
        _arguments:
          model: testmodel
      -
        routePath: '/bugupdate/{model}'
        _controller: 'Testmodel::show'
        _arguments:
          model: testmodel
      -
        routePath: '/bugdelete/{model}'
        _controller: 'Testmodel::show'
        _arguments:
          model: testmodel
      -
        routePath: '/bugcreate/'
        _controller: 'Testmodel::create'
      -
        routePath: '/bugnew/'
        _controller: 'Testmodel::new'
    defaultController: 'Testmodel::list'
    aspects:
      model:
        type: PersistedAliasMapper
        tableName: tx_bugtest_domain_model_testmodel
        routeFieldName: path_segment 

As a general hint, ensure not to use the
`features.skipDefaultArguments` setting for
your plugin.

# extension ext_tables.sql 
CREATE TABLE tx_bugtest_domain_model_testmodel(
  path_segment varchar(2048),
  KEY path_segment (path_segment(127))
);

and the TCA example for that field and your table (partly)

[
    'columns' => [
        'path_segment' => [
            'exclude' => 1,
            'label' => 'slug_1',
            'description' => 'field description',
            'config' => [
                'type' => 'slug',
                'generatorOptions' => [
                    'fields' => [
                        'input_1',
                        'input_2',
                    ],
                    'fieldSeparator' => '/',
                    'prefixParentPageSlug' => true,
                    'replacements' => [
                        '/' => '',
                    ],
                ],
                'fallbackCharacter' => '-',
                'eval' => 'uniqueInSite',
                'default' => '',
            ],
        ],
    ],
]

[1] https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Routing/AdvancedRoutingConfiguration.html#extbase-plugin-enhancer
[2] https://docs.typo3.org/m/typo3/reference-tca/11.5/en-us/ColumnsConfig/Type/Slug/Index.html

Actions #2

Updated by Dieter Dr. Porth 5 months ago

Your suggestions didn't solve the problem. I also have incorrect behavior with your instructions.
Not even the links to the forms worked with the aspects.
(See modified extension). (Cause?: The data records are written to page 0 by the plugin.)

Without the aspects, the UID is adopted as a value, which from my understanding should also be standard behavior.

So in my version I can define links that point directly to the `Edit` form or `EditTwo` form. But as soon as I call up the corresponding form using the button with the corresponding action value in the form, the corresponding link is not displayed as a result in the address bar of the browser.
All links in the list-view works fine, so I think, the configuration is correct.

To call up the form `editTwo`, I would have expected the following link in adressline of the browser, analogous to the link in the list view:
https://bugtest.ddev.site/bereich-personal/stelle-ausschreiben/bugtest/bugedittwo/1

When I enter the attribute `action="update"` in Edit's template for f:form, I found the incorrect URL in the address line
https://bugtest.ddev.site/bereich-personal/stelle-ausschreibe/bugtest?tx_bugtest_routingtest%5Baction%5D=update&tx_bugtest_routingtest%5Bcontroller%5D=Testmodel&cHash=caf03268fea2493bc9302787200df133
Incorrect because the UID of the element to be updated is missing.

If I remove the action="update" attribute from f:form in the 'edit' template, then I found the meaningless URL (default Url) in the browser's address line
https://bugtest.ddev.site/bereich-personal/stelle-ausschreiben/bugtest/list

Actions

Also available in: Atom PDF