2017-10-04 15 views
0

リダイレクトまたはフォワード機能を使用して別のアクションにリダイレクトする方法はありますか?私のソリューションは、TYPO3 extbase forward、リダイレクトアクション

<f:widget.paginate objects="{products}" as="paginatedProducts" 
     configuration="{itemsPerPage: 10, insertAbove: 0, insertBelow: 1, maximumNumberOfLinks: 10}"> 
      <f:for each="{paginatedProducts}" as="productx"> 

        <tr>  
          <td align="top">{productx.uid}</td> 
          <td align="top">{productx.name}</td> 
          <td align="top"><f:format.crop maxCharacters="100">{productx.description}</f:format.crop></td> 
          <td align="top">{productx.quantity}</td> 
        </tr> 
      </f:for> 
       </f:widget.paginate> 
    </table> 

</div> 
<div class="col-sm-5"> 

<f:form method="post" controller="Inventory" action="show" name="searchProduct" object="{searchProduct}"> 
<label> Product Name <span class="required"></span><br /> 
    <f:form.textfield property="name" /></label><br /> 
<f:form.submit class="submit" value="Submit"/> 

(ない新しいファイルshow.htmlを作成することによって)、私は同じページにfoundProductを表示しようとしているビューで

public function listAction() { 
    $products = $this->productRepository->findAll(); 
    $this->view->assign('products', $products); 
} 

public function showAction() { 
    $var = $this->request->getArgument('searchProduct'); 
    $foundProd = new \MyVendor\Inventory\Domain\Model\Product($var);  
    $prod = $this->productRepository->getProduct($foundProd); 
    \TYPO3\CMS\Core\Utility\DebugUtility::debug($prod); 

    $this->view->assign('test',$prod); 
    $this->redirect('list',NULL,NULL,array('')); 
    // $this->forward('list',NULL, NULL, $this->request->getArguments()); 
} 

を動作するようには思えません

<div> 
<f:for each ="{test}" as ="p"> 
    <P>Numele produsului : {p.name}</P> 
    <p>Descriere : {p.description}</p> 
    <p>Cantitate : {p.quantity} </p> 
</f:for> 
</div> 
</div> 

EDIT:list.html file. Basically when i click Submit i want to show on the same page the product found from the database.

This is how it works atm

+0

上記のテンプレートを記入します。それはあなたがしたいことですか? –

+0

私は両方のアクションが同じページ(.htmlファイル)で実行されることを望みます。 Typo3ちょっと私は、それぞれのアクション、私の場合list.htmlとshow.htmlでは、別の.htmlファイルを作成する必要があります。 show.htmlを作成する代わりに、list.htmlでshowActionを実行します。 –

+0

私はそれの背後にある考えを得ることができません。 'showAction'は何かを表示するはずです。ほとんどの場合、ニュース拡張機能の詳細ビューのようなレコードの詳細です。リダイレクトを使用する唯一の時間は、たとえば変更を保存した後、レコードを更新してリストに戻る。あなたはあなたの行動を過ちて、そこで何をすべきかを考えなければなりません。 –

答えて

0

このようには動作しません。 redirectまたはforwardを使用すると、変数の割り当てがリセットされます。

あなたはlistAction内の複数のプロパティを割り当てることができます。

public function listAction() { 
    $products = $this->productRepository->findAll(); 

// from your showAction 
    $var = $this->request->getArgument('searchProduct'); 
    $foundProd = new \MyVendor\Inventory\Domain\Model\Product($var);  
    $prod = $this->productRepository->getProduct($foundProd); 


    $this->view->assignMultiple(
     array(
      'products' => $products, 
      'test' => $prod 
     ) 
    ); 
} 

これはあなたのコードはlistAction` `にあなたが` showAction`を実行するたびにリダイレクトするように見えるあなたが

+0

これを行いましたが、次のエラーが表示されます。このリクエストでは、「searchProduct」引数が存在しません。 このエラーに関する詳細は、オンラインで入手できます。おそらく、エラーはこの行を参照しています。

関連する問題