在 TYPO3 9.5.5 中为表单提交操作配置静态路由

Configure static route for form submit action in TYPO3 9.5.5

我有一个在前端呈现表单的 Extbase 扩展,我的 URL 如下所示:

https://domain.ch/de/news/add/?tx_newsform%5Baction%5D=new&tx_newsform%5Bcontroller%5D=News&cHash=041eab0915b1445827046afef933eb26

我需要一个用于提交操作的静态路由。我在下面添加了 YAML 配置。

routeEnhancers:
  NewsFormPlugin:
    type: Extbase
    extension: NetcNewsform
    plugin: netcnewsform
    routes:
      - { routePath: '/new-article/success', _controller: 'News::create'}

    defaultController: 'News::new'
    requirements:
       page: '\d+'

这在表单操作中显示了完美的静态路由,但是当我提交表单时,这不会在浏览器中显示相同的 URL。

有人可以指导我吗?非常感谢!

我已经解决了这个问题,我犯了一个小错误导致了这个问题。我的操作重定向到控制器的 New 操作,我在 YAML 配置中传递了错误的操作。

routeEnhancers:
  NewsFormPlugin:
    type: Extbase
    extension: NetcNewsform
    plugin: netcnewsform
    routes:
      - { routePath: '/new-article/success', _controller: 'News::create'} # Here is the issue

    defaultController: 'News::new'
    requirements:
       page: '\d+'

我没有使用上面的配置,而是使用了下面的配置。

  NewsFormPlugin:
    type: Extbase
    extension: NetcNewsform
    plugin: netcnewsform
    routes:
        - { routePath: '/new-article/success', _controller: 'News::create'}
        - { routePath: '/new-article/success', _controller: 'News::new'}

    defaultController: 'News::new'
    requirements:
      page: '\d+'

还有一件事,我为 createnew 操作都添加了路由。

这个效果很好!