---
title: "Einfaches redirect nach create funktioniert nicht ... ?"
url: "https://www.typo3.net/d/111560-einfaches-redirect-nach-create-funktioniert-nicht"
source: "typo3.net"
tags: ["Extensions","Extbase","Frage"]
created: "2012-07-31"
last_reply: "2012-07-31"
replies: 4
solved: false
page: 1
pages: 1
lang: "de"
---

# Einfaches redirect nach create funktioniert nicht ... ?

Extensions › Extbase · 4 Antworten · gestartet 2012-07-31

## Eröffnungsbeitrag

**mimaxx** · 2012-07-31 · [Beitrag #1](https://www.typo3.net/d/111560-einfaches-redirect-nach-create-funktioniert-nicht/1)

Hallo,

möchte gern nach dem Anlegen einer neuen Nachricht eine Weiterleitung auf die showAction. Es kommt jedoch folgender Fehler:

#1217839467: Could not ultimately dispatch the request after 101 iterations. Most probably, a @dontvalidate annotation is missing on re-displaying a form with validation errors.

New.html

```html
<f:form method="Post" controller="Posts" action="create"  name="newPosts" object="{newPosts}">
				
	
		<label for="postTitle">Titel</label>
		<f:form.textfield name="postTitle" property="postTitle" /><br>
		
		<label for="forumsId">ForumsID</label>
		<f:form.textfield name="forumsId" property="forumsId" value="{forum.uid}"/><br>	
		
		<label for="forumsId">Text</label>
		<f:form.textarea name="postText" property="postText" rows="20" cols="46" /><br>
	
		<f:form.submit value="Speichern" />
</f:form>
```

PostsController.php

```php
	/**
	 * action show
	 *
	 * @param Tx_MyForum_Domain_Model_Posts $posts
	 * @return void
	 */
	public function showAction(Tx_MyForum_Domain_Model_Forum $forum, Tx_MyForum_Domain_Model_Posts $posts) {
		$this->view->assign('posts', $posts);
		$this->view->assign('forum', $forum);
	}

	/**
	 * action new
	 *
	 * @param Tx_MyForum_Domain_Model_Posts $newPosts
	 * @dontvalidate $newPosts
	 * @return void
	 */
	public function newAction(Tx_MyForum_Domain_Model_Forum $forum, Tx_MyForum_Domain_Model_Posts $newPosts = NULL) {
		$this->view->assign('newPosts', $newPosts);
		$this->view->assign('forum', $forum);
	}

	/**
	 * action create
	 *
	 * @param Tx_MyForum_Domain_Model_Posts $newPosts
	 * @return void
	 */
	
	public function createAction(Tx_MyForum_Domain_Model_Posts $newPosts, Tx_MyForum_Domain_Model_Forum $forum) {
		$this->postsRepository->add($newPosts);
		$this->flashMessageContainer->add('Your new Posts was created.');
		#$this->redirect('list','Forum');
		$this->redirect('show', NULL, NULL, array('posts' => $newPosts));
		#$this->forward('show', 'Posts', NULL, array('posts' => $newPosts));
	}
```

Gruss
mimaxx

## Antworten

### [#2](https://www.typo3.net/d/111560-einfaches-redirect-nach-create-funktioniert-nicht/2) · LuP · 2012-07-31

Hallo,

```php
/**
 * action show
 *
 * @param Tx_MyForum_Domain_Model_Posts $posts
 * @dontvalidate $posts
 * @return void
 */
  public function showAction(Tx_MyForum_Domain_Model_Forum $forum, Tx_MyForum_Domain_Model_Posts $posts) {
    $this->view->assign('posts', $posts);
    $this->view->assign('forum', $forum);
  }
```

VG,
LuP

### [#3](https://www.typo3.net/d/111560-einfaches-redirect-nach-create-funktioniert-nicht/3) · mimaxx · 2012-07-31

Hallo LuP,

erstmal Danke für die schnelle Antwort, aber das brachte noch nicht den gewünschten Erfolg.

Habe * @dontvalidate $newPosts in die showAction hinzugefügt. Cache geleert aber immer noch der gleiche Fehler.

Gibt es noch andere Dinge die ich beachten muss? Ist der Aufruf mit

```php
$this->redirect('show', NULL, NULL, array('posts' => $newPosts));
```

denn korrekt?

Gruss
mimaxx

### [#4](https://www.typo3.net/d/111560-einfaches-redirect-nach-create-funktioniert-nicht/4) · LuP · 2012-07-31

sorry, habe vorhin wegen redirect nicht gut aufgepasst. Ein anderer Ansatz:

```php
/**
 * show action
 *
 * @return void
 */
public function showAction() {
    $mappingArr = array(
        'posts' => $this->postsRepository,
        'forum' => $this->forumRepository
    );

    foreach($mappingArr as $name => $repo) {
        if($this->request->hasArgument($name)) $this->view->assign($name, $repo->findByUid($this->request->getArgument($name)));
    }
}
```

VG,
LuP

### [#5](https://www.typo3.net/d/111560-einfaches-redirect-nach-create-funktioniert-nicht/5) · LuP · 2012-07-31

mein vorheriger Ansatz dürfte auch noch nicht funktionieren. Nimm forward statt redirect:

```php
/**
 * show action
 *
 * @return void
 */
public function showAction() {
    $mappingArr = array('posts', 'forum');

    foreach($mappingArr as $name) {
        if($this->request->hasArgument($name)) $this->view->assign($name, $this->request->getArgument($name));
    }
}

/**
 * action create
 *
 * @param Tx_MyForum_Domain_Model_Posts $newPosts
 * @return void
 */
public function createAction(Tx_MyForum_Domain_Model_Posts $newPosts, Tx_MyForum_Domain_Model_Forum $forum) {
    $this->postsRepository->add($newPosts);
    $this->flashMessageContainer->add('Your new Posts was created.');
    $this->forward('show', NULL, NULL, array('posts' => $newPosts));
}
```

VG,
LuP

---

Quelle: „Einfaches redirect nach create funktioniert nicht ... ?“, typo3.net, https://www.typo3.net/d/111560-einfaches-redirect-nach-create-funktioniert-nicht
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
