Passing variables to controller with URL

Permalink
On my dashboard single page, I want to pass 2 variables to the remove function in the controller. In the view I have this:

echo '<a class="btn btn-primary btn-sm" href="'.View::url('dashboard/emp_apps/department_view/remove/'.$dpt['dptID'].'/'.$dpt['bID']).'">'.t('Remove').'</a>';


And in the controller I have the remove function:

public function remove($dptid = NULL, $bID = NULL) {
      echo '<script>alert("dptID=".$dptID);</script>';
      echo '<script>alert("bID=".$bID);</script>';
}


Both variables are 'undefined'. But when I only pass 1 variable, this is the view:

echo '<a class="btn btn-primary btn-sm" href="'.View::url('dashboard/emp_apps/department_view/remove/'.$dpt['dptID'].'">'.t('Remove').'</a>';


and this is the function in the controller:

public function remove($dptid = NULL) {
      echo '<script>alert("dptID=".$dptID);</script>';
}


and it works fine. Why can't I pass 2 variables to the remove function?

 
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
Try to pass it like:
echo '<a class="btn btn-primary btn-sm" href="'.View::url('dashboard/emp_apps/department_view/remove/', $dpt['dptID'], $dpt['bID']).'">'.t('Remove').'</a>';

I think it will work.
Annalyzer replied on at Permalink Reply
It didn't work. They are both still undefined.
Annalyzer replied on at Permalink Reply
Nevermind. It did work, I just wasn't seeing it because I had mistakes in the function. Should have been:

public function remove($dptID = NULL, $bID = NULL) {
      echo '<script>alert("dptID='.$dptID.'");</script>';
      echo '<script>alert("bID='.$bID.'");</script>';
}


Thank you for your help!