2016-11-04 101 views
1

在我的extbase擴展中我有一個預約模型,用戶可以寫預約方式的反饋。
所以我創建了一個不同領域的反饋模型。
現在,當用戶點擊「創建反饋」按鈕時,我應該執行什麼?
到目前爲止,我得到了這一點,但它不工作:將參數傳遞給其他控制器或替代品

<f:link.action action="edit" controller="Feedback" arguments="{appointment:appointment}"> 

我得到的錯誤:

Argument 1 passed to ...Controller\FeedbackController::newAction() must be an instance of ...\Model\Appointment, none given

FeedbackController:

 /** 
    * action new 
    * @param ...\Domain\Model\Appointment $appointment 
    * @return void 
    */ 
    public function newAction(...\Domain\Model\Appointment $appointment) { 
     $this->view->assign('appointment', $appointment); 
    } 

爲什麼我得到這個錯誤? (約會對象肯定在那裏,我調試了它)
我認爲它必須與從AppointmentController切換到FeedbackController有關。

實現此目的的最佳方式是什麼?

+1

如何生成的鏈接是什麼樣子?有約會uid禮物嗎?您的插件/控制器是否允許訪問保存預約記錄的存儲文件夾? – minifranske

回答

4

如果您使用不同的插件,則需要鏈接生成中的pluginName參數。

<f:link.action action="edit" controller="Feedback" pluginName="your_plugin" arguments="{appointment:appointment}"> 

當生成鏈路TYPO3預先考慮的參數是這樣的鏈路的「命名空間」:tx_myplugin [動作] =新。確保pluginName與您在ext_localconf.php中定義的相同。在這種情況下,pluginName將是your_plugin。

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Vendor.' . $_EXTKEY, 
    'your_plugin', 
    array(
     'Feedback' => 'new', 
    ), 
    // non-cacheable actions 
    array(
     'Feedback' => '', 
    ) 
); 
+0

我想我也需要它在我的情況下 - 不使用不同的插件?! 因爲它確實是它顯然不工作的原因,即使我只使用一個插件(我認爲):)謝謝! –

0

檢查ext_localconf.php中的plugin-controller-action數組並將其發佈。也許有什麼問題。

0

如果您收到此錯誤:

Argument 1 passed to ...Controller\FeedbackController::newAction() must be an instance of ...\Model\Appointment, none given

那是因爲你給CONTROLER一個空對象和taht是不允許與您的控制器。

爲了避免這種錯誤,你可以允許空物體在你的控制器:

/** 
    * action new 
    * @param ...\Domain\Model\Appointment $appointment 
    * @return void 
    */ 
    public function newAction(...\Domain\Model\Appointment $appointment=NULL) { 
     $this->view->assign('appointment', $appointment); 
    } 

這是奇怪,因爲在你的鏈接,你叫一個動作「編輯」,你必須在「newAction」控制器錯誤而不是「editAction」控制器,你應該讓你的插件(可高速緩存與否)的「編輯」行爲:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Vendor.' . $_EXTKEY, 
    'your_plugin', 
    array(
     'Feedback' => 'edit', 
    ), 
    // non-cacheable actions 
    array(
     'Feedback' => 'edit', 
    ) 
); 

和納塔利婭寫道添加插件名稱,如果你要撥打的行動屬於另一個插入。

<f:link.action action="edit" controller="Feedback" pluginName="your_plugin" arguments="{appointment:appointment}"> 

弗洛裏安

相關問題