Geee
Geee

Reputation: 2243

Configure static route for form submit action in TYPO3 9.5.5

I have an Extbase extension which renders the form in the frontend and my URL is as below:

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

I need a static route for the submit action. I have added below YAML configuration.

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

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

This shows perfect static route in the form action, but while I submit the form this won't show the same URL in the browser.

enter image description here

Can anyone guide me? Big thanks!

Upvotes: 2

Views: 605

Answers (1)

Geee
Geee

Reputation: 2243

I have fixed the issue, I had made a minor mistake which causes the issue. My action redirects to the New action of the controller and I had passed the wrong action at the YAML configuration.

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+'

Instead of the above configuration, I used the below configuration.

  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+'

One more thing, I have added routes for create and new action both.

This working pretty well!

Upvotes: 2

Related Questions