Warning: trim() expects parameter 1 to be string

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
ross_t
User
Posts: 139

Warning: trim() expects parameter 1 to be string

Post by ross_t »

I've different User Levels: Administrator, Reseller, User, Guest.

Administrator and Reseller can create new Users under them. Administrator can create any User whilst Reseller can create users except of type "Administrator". "Guest" is the default user level assigned to the User upon registration.

So, in order to implement this, I wanted to hide all other User Levels for Reseller account. Since "User Level" is a Look up Drop-down field, I added Filter "userlevelid >= 1" for look-up field in Field Settings.

I see no Warning for "Add User" page; but I see following warning message on Edit and View pages; the set filter also fails and all User Levels are exposed to Reseller on Edit page.

Warning: trim() expects parameter 1 to be string, object given in D:\path\to\application\phpfn15.php on line 7878

Everything works good on Add page.

The function at given line number 7878 is:

// Add filter
function AddFilter(&$filter, $newfilter) {
if (trim($newfilter) == "") return;
if (trim($filter) <> "") {
$filter = "(" . $filter . ") AND (" . $newfilter . ")";
} else {
$filter = $newfilter;
}
}

The if (trim($newfilter) == "") return; is the line at line number 7878.

I'm clueless; please guide me to solve this issue.

Thanks!


sangnandar
User
Posts: 980

Post by sangnandar »

I also have some problems with Filter (table filter). I have no idea why it happens but moving the filter into related server event solved the problems.


ross_t
User
Posts: 139

Post by ross_t »

Yes, I moved the Filter to Lookup_Selecting and it solved the problem. Thanks so much for your quick help @sangnandar !!


aniederer
User
Posts: 5

Post by aniederer »

That is not a solution. It is an alternative exit. There is an error in the conversion from int to string or something happens with the function or as the function is called. The same code in the previous version, did not give problem


Webmaster
User
Posts: 9427

Post by Webmaster »

Make sure you use v2019.0.8 (or newer).


Post Reply