[TYPO3-mvc] How do i use forward , redirect to another action ?

Andrei Teianu andreiteianu at gmail.com
Wed Oct 4 13:46:17 CEST 2017


Hello , i'm new to typo3 and i can't seem to understant how these functions work. 
I'm trying to find a product in the database from a form and return it to the view . The code works if i create a new html show.html . Thank you for your help . 
Here is my code . 
Controller 
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());
     
View snippet
<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"/>
  </f:form> 
  <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>
  </div>



More information about the TYPO3-project-typo3v4mvc mailing list