extbase 操作总是显示错误的流体模板

extbase action always shows wrong fluid template

我在 tx_news 上做了几个扩展:

1) 我向 newscontroller 添加了三个新操作。前两个动作按预期进行。动作 eventDetail 显示一个表单。流畅的代码是

<f:form class="form-horizontal" noCacheHash="true" pageUid="30" action="createApplication" name="newApplication" object="{newApplication}" arguments="{news : newsItem, currentPage: 0, application: newApplication}" enctype="multipart/form-data">
            <f:form.textfield class="form-control" property="name" size="40" required="required" />
            <f:form.hidden name="newsItem" value="{newsItem}" />
            <f:form.submit class="btn btn-primary" value="{f:translate(key:'submitApplyJob')}submit" />
        </f:form>

创建应用程序的操作:

 /**
 * action createApplication
 *
 * @param \FalkRoeder\DatedNews\Domain\Model\Application $newApplication
 * @param \GeorgRinger\News\Domain\Model\News $news news item
 * @return void
 */
public function createApplicationAction(\GeorgRinger\News\Domain\Model\News $news, $currentPage = 1, \FalkRoeder\DatedNews\Domain\Model\Application $newApplication) {

    if (is_null($news)) {
        $previewNewsId = ((int)$this->settings['singleNews'] > 0) ? $this->settings['singleNews'] : 0;
        if ($this->request->hasArgument('news_preview')) {
            $previewNewsId = (int)$this->request->getArgument('news_preview');
        }

        if ($previewNewsId > 0) {
            if ($this->isPreviewOfHiddenRecordsEnabled()) {
                $GLOBALS['TSFE']->showHiddenRecords = true;
                $news = $this->newsRepository->findByUid($previewNewsId, false);
            } else {
                $news = $this->newsRepository->findByUid($previewNewsId);
            }
        }
    }

    if (is_a($news,
            'GeorgRinger\News\Domain\Model\News') && $this->settings['detail']['checkPidOfNewsRecord']
    ) {
        $news = $this->checkPidOfNewsRecord($news);
    }

    if (is_null($news) && isset($this->settings['detail']['errorHandling'])) {
        $this->handleNoNewsFoundError($this->settings['detail']['errorHandling']);
    }

    $newApplication->setTitle($newsItem->getTitle()." - ".$newApplication->getName() . ', ' . $newApplication->getSurname());

    $this->applicationRepository->add($newApplication);
    $persistenceManager = GeneralUtility::makeInstance("TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager");
    $persistenceManager->persistAll();

    $newsItem->addApplication($newApplication);
    $this->newsRepository->update($newsItem);

    $demand = $this->createDemandObjectFromSettings($this->settings);
    $demand->setActionAndClass(__METHOD__, __CLASS__);

    $assignedValues = [
        'newsItem' => $news,
        'currentPage' => (int)$currentPage,
        'demand' => $demand,
        'newApplication' => $newApplication
    ];

    $assignedValues = $this->emitActionSignal('NewsController', self::SIGNAL_NEWS_CREATEAPPLICATION_ACTION, $assignedValues);
    $this->view->assignMultiple($assignedValues);


}

问题是,在提交表单后,它显示了 pid 30 的正确页面,但它显示了操作 eventDetail 的流体模板的内容。应用程序数据未存储在数据库中。

第二个奇怪的事情是,如果我从表单中删除参数 currentPage,我会得到一个错误,指出参数丢失,因为它是动作定义所需要的。这告诉我需要正确的操作。

我不明白这个问题。只想执行操作并显示名为 CreateApplication.html 的流体模板。

如果需要更多信息,我会添加。

更新: 如果我为我的操作添加一个初始化方法,它将被调用并且参数被正确调试:

public function initializeCreateApplicationAction(){
    \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->request->getArguments(),'NewsController:139');

}

但它仍然切换到错误的流体模板。

我要做的第一件事是将@params 的顺序与方法的参数顺序相匹配。

并且 Fluid 中 arguments={} 中提供的参数命名不匹配,例如应用程序与新应用程序

wong 重定向是验证错误的结果。在我的应用程序模型中,我设置了另外两个带有验证 "notEmpty" 的字段,但没有将其与表单一起发送。将这两个字段添加到表单中并为它们赋值会导致正确的结果。

进一步说明:

如果域模型对象验证失败,将调用 class“\TYPO3\CMS\Extbase\Mvc\Controller\ActionController”的错误操作,并转发到引用请求。