繁体   English   中英

TYPO3 创建帖子后重定向到 ShowAction

[英]TYPO3 Redirect to ShowAction af creating post

我正在使用 extension_builder 构建自己的扩展。
将数据放入数据库后,我需要它到 go 到 Show Action。

这是我的创建动作

/**
 * action create
 * 
 * @param \Originalen\OrigWhistleblower\Domain\Model\Whistleblower $newWhistleblower
 * @return void
 */
public function createAction(\Originalen\OrigWhistleblower\Domain\Model\Whistleblower $newWhistleblower)
{
    $this->whistleblowerRepository->add($newWhistleblower);

    $this->redirect('show', 'Whistleblower', 'orig_whistleblower', ['whistleblower' => $this]);
    //$this->redirect('show');
}

但是我收到一条错误消息,说Required argument "whistleblower" is not set for Originalen\OrigWhistleblower\Controller\WhistleblowerController->show.

您需要将 object 传递给 arguments。 您的$this变量是实际的 class 而不是新的 object。 您应该将其替换为$newWhistleblower

$this->redirect('show', 'Whistleblower', 'orig_whistleblower', ['whistleblower' => $newWhistleblower]);

同时,我会在直接之前将其持久化,以确保(将其保存在数据库中。add add->()命令尚未保存 object)。

$this->persistenceManager->persistAll();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM