2016-06-15 2 views
0

cakephp2 검색 기능을 cakephp3으로 변환 중입니다. 저는 post 매개 변수를 매개 변수로 변환합니다. 주소 표시 줄에 쿼리 문자열로 나타나는 올바른 매개 변수를 얻을 수 있지만 아래의 for 루프 변수에 액세스 할 때 출력이 없습니다. 내가 잘못하고있는 것을 볼 수는 없으며 문서에서 대답을 찾을 수 없습니다.cakephp3 검색 함수에 대해 GET 매개 변수를 얻을 수 없습니다.

cakephp3의 foreach 루프에서 GET 매개 변수를 얻으려면 어떻게해야합니까?

 if ($this->request->is('post')) { 


     $filter_url['controller'] = $this->request->params['controller']; 
      $filter_url['action'] = $this->request->params['action']; 
      $filter_url['page'] = 1; 

    // for each filter we will add a GET parameter for the generated url 
    foreach($this->request->data as $name => $value){ 
     if($value){ 
      $filter_url[$name] = urlencode($value); 
     } 
    } 
    //Post params are now GET paramaters 
    return $this->redirect($filter_url); 


    } 




debug($this->request->params['pass']); //outputs nothing 


     foreach($this->request->params['pass'] as $param_name => $value): 
     // debug($param_name); 
      // debug($value); 
      if ($param_name=='lastname') $searchLastName =$value; 
      if ($param_name=='firstname') $searchFirstName =$value; 


     endforeach; 

//view 
<?php echo $this->Form->create(); ?> 
    <table cellpadding="0" cellspacing="0"> 
     <thead> 
      <tr> 


       <td><?php echo $this->Form->input('firstname',['label' => 'FirstName']); ?></td> 
       <td><?php echo $this->Form->input('lastname',['label' => ' LastName']); ?></td> 
       <td> <?php //echo $this->Form->button('Submit Form', ['name'=>'search','type' => 'submit']); ?></td> 
      </tr> 
     </thead> 

    <?= $this->Form->button('Submit Form', ['name'=>'search','type' => 'submit']); ?> 
    <?= $this->Form->end() ?> 

http://book.cakephp.org/3.0/en/controllers/request-response.html 

답변

0

이것은

foreach($this->request->query as $param_name => $value): 

       if ($param_name=='lastname') $searchLastName =$value; 
       if ($param_name=='firstname') $searchFirstName =$value; 


      endforeach; 
근무
관련 문제