Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Problem with Criteria::fromInput - BUG ?

I use the following code:

$query = Criteria::fromInput($this->di, 'Objects', $array);
$this->persistent->searchParams = $query->getParams();

if ($this->persistent->searchParams) {
    $parameters = $this->persistent->searchParams;

$objects = Objects::find($parameters);

The problem is, when I have only one value in $array (Array ( [country_id] => HR )) , I get ''Undefined variable ""parameters"" error.

When I have multiple values, it works fine.

Is this a bug or is it supposed to work like this?


To avoid that error you can change it to:

$query = Criteria::fromInput($this->di, 'Objects', $array);

$objects = Objects::find($query->getParams());


This is not solving the problem.

If $array has only one parameter, $query->getParams() returns nothing.

If it has more that one, it's ok..

It does seem to me like a bug, this is my full searchAction code:


Ok, i found my error... I should have used ccfips instead of countryid