Bounce
Bounce

Reputation: 2105

Joomla 2.5 getUserStateFromRequest load error

I was following the example to implement custom filters in Joomla 2.5 admin component.

But I am getting error at models populateState method:

Call to undefined method somecompModelsomecomp::getUserStateFromRequest().

$app = JFactory::getApplication('administrator');
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');

Error disappears if I call getUserStateFromRequest using $app:

$app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');

So whats the problem? In default Joomla components I've seen that it use the same approach and it works. Maybe I miss something in my model class?

Any ideas?

Upvotes: 0

Views: 2172

Answers (1)

Toretto
Toretto

Reputation: 4711

This is happened because $app is an object of your application class. As you defined it in your code.

$app = JFactory::getApplication('administrator');

and getUserStateFromRequest method is defind in that Application class.so you have to use it like this if you want to access this method.

$app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');

And for your information $this variable is your local object.

Upvotes: 2

Related Questions