Paginator with Criteria::fromInput and Multiple Models

Hi, how use Criteria::fromInput with two or more Models related.

        $query = Criteria::fromInput($this->di, "Robot", $_POST);
edited Feb '16

Example using column map with the two first letters of each word of the model name as alias prefix column :

$currentPage = 1;
if($this->request->isPost()){
    $query = Criteria::fromInput($this->di, 'Robot', $_POST);
    $query->join('RobotPart', 'ro_id = ropa_robot_id');
    $params = $query->getParams();

    $queryPart = Criteria::fromInput($this->di, 'RobotPart', $_POST); 
    $paramsPart = is_null($queryPart->getParams()) ? null : $queryPart->getParams();
    if(!is_null($paramsPart)){
        $params['conditions'] .= ' and '.$paramsPart['conditions'];
    }
    $this->persistent->parameters = $params;
} else {
    $currentPage = $this->request->getQuery("page", "int");
}
$parameters = $this->persistent->parameters;
if (!is_array($parameters)) {
    $parameters = [];
}
$robots = Robot::find($parameters);
if (count($robots) == 0) {
    $this->flash->notice("The search did not find any robot");
    // ...
}
$paginator = new Paginator([
    "data" => $robots,
    "limit"=> 20,
    "page" => $currentPage
]);
$this->view->page = $paginator->getPaginate();

Excelent, i will test. Thanks!

I made some mistakes, I've updated the answer.