Search code examples
getkohana-3.2

How to get GET params from view to controller with anchor tag in Kohana 3.2


I have an anchor in view:

echo HTML::anchor("admin/supm_find?page=".($page+1).'&tselected='.$selected, "Next");

Wenn, i ckick on anchor tag, that's call "admin" contorller with "supm_find" action and "page" and "selected" params.

In controller:

$selected=$this->request->post('selected');
$page=$this->request->post('page');

but, the both variables value is NULL! What's wrong? In error message i see this :

 SYSPATH\classes\kohana\request\client\internal.php [ 116 ] » ReflectionMethod->invoke(arguments) 

        protected _get => array(2) (
        "page" => string(1) "2"
        "selected" => string(7) "Wien"

How to get these values?


Solution

  • This should work:

    $selected=$this->request->query('selected');
    $page=$this->request->query('page');
    

    $this->request->post() operate on $_POST array,

    $this->request->query() operate on $_GET array

    $this->request->param() operate on kohana route params

    You can read more here: http://kohanaframework.org/3.1/guide/api/Request