Joomla 2.5 getUserStateFromRequest load error-Collection of common programming errors
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?
-
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.
Originally posted 2013-11-09 20:02:44.