2017-01-23 2 views
0

私はtx_newsでいくつかの拡張を行っています:extbaseアクションが間違った流体テンプレートを常に表示する

1)私はnewscontrollerに3つの新しいアクションを追加しました。最初の2つのアクションは期待どおりに機能しています。アクション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> 

アクションcreateApplicationである:それは、PID 30で正しいページを表示するが、それはの流体テンプレートの内容を示してフォームを送信した後

/** 
* 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); 


} 

問題は、ありますアクションeventDetailアプリケーションデータはDBに格納されません。

2番目の奇妙なことは、フォームから引数currentPageを削除すると、アクションの定義に必要なために引数が欠落しているというエラーが表示されます。それは正しい行動が要求されることを私に伝えます。

この問題はわかりません。アクションを実行し、CreateApplication.htmlという流体テンプレートを表示したいだけです。

さらに詳しい情報が必要な場合は、追加します。

UPDATE: 私は自分の行動のためのinitializeメソッドを追加した場合、それが呼び出され、引数が正しくデバッグされています

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

} 

しかし、まだそれは、間違った流体のテンプレートに切り替わります。

答えて

0

wongリダイレクトは、検証エラーの結果でした。私のアプリケーションモデルでは、 "notEmpty"というバリデーションで2つのフィールドを設定しましたが、フォームで送信しませんでした。これらの2つのフィールドをフォームに追加し、それらに値を与えることで正しい結果が得られます。

さらに説明:ドメインモデルオブジェクトの検証が失敗した場合

、クラスのerrorActionという "\ TYPO3 \ CMS \ Extbase \ MVC \コントローラ\ ActionControllerは" と呼ばれ、これは参照要求に転送します。

0

まず、@paramsの順序をメソッドのパラメータの順序と一致させることです。

そして、Fluidの引数= {}に指定されているパラメータの名前が一致しません。アプリケーションとnewApplication

+0

ありがとうございました。適合しました。しかし、私の主な問題は何も変えていない。 – Falk

+0

typo3/sysext/fluid/Classes/View/TemplateView.phpのgetTemplatePathAndFilename()メソッドでデバッグできます。デバッガを使用するか、そこにあるログファイルに何らかの書き込みを追加するだけです。これは、どのパラメータが提供されているか、どのテンプレートファイルを試しているかの洞察を得るのに役立ちます。 – Claudia

関連する問題