簡體   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