2011-12-12 9 views
0

컨트롤러에 검색 기능이 있습니다. 컨트롤러에서 볼 수있는 2 개의 변수를 컨트롤러로 보내려합니다. $id$value . 검색 유형을 선택하고 검색 할 입력을 허용하기 위해 드롭 다운을 사용하기 때문입니다.이 작업을 수행하는 가장 좋은 방법은 무엇입니까? 양식 데이터를 전송하기 위해 get 메소드를 사용할 수 있습니다보기에뷰에서 컨트롤러로 데이터를 보내는 방법 cakephp

crontroller

function search($id, $value) { 
    switch($id) 
    { 
    case '0': 
     // todo 
    break; 

    case '1': 
     // todo 
    break; 

    case '2': 
     // todo 
    break; 

    case '3': 
     // todo 
    break; 

    default: 
     $this->set('dishes', $this->Dish->find('all')); 
    break; 
    } 
    $this->layout = 'main_layout'; 
} 
+0

에서보기

$this->Form->create('Model', array('type' => 'get', 'action' => 'search')); $this->Form->input('select_tfield_id', array('type' => 'select')); $this->Form->input('value')); $this->Form->end('submit'); 

에서

당신은 잠재적으로 컨트롤러에서 다른 행동을, 아약스 요청을 할 필요가있다. – Dunhamzzz

답변

2

. 컨트롤러의 액션에서는 전달 된 인수에 $ this-> params [ 'url'];로 접근 할 수 있습니다. 컨트롤러

function search() { 
     $url = $this->params['url']; 
     $id = $url['select_tfield_id']; 
     $value = $url['value']; 
    } 
관련 문제