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?



85.4k

To avoid that error you can change it to:

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

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


11.2k

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: http://pastebin.com/4psXDHSr



11.2k
Accepted
answer

Ok, i found my error... I should have used cc_fips instead of country_id