Fatal error: Call to undefined method – Joomla 3 Component Development

When creating a Joomla 3 component, you can declare functions / methods within your models. When calling these methods in your views, you might see an error similar to the following:

Fatal error: Call to undefined method ComponentViewName::yourMethod() in /home/userna5/public_html/components/com_component/views/component/view.html.php on line 19

This error can be resolved using the getModel method, and this is how you can edit your view.html.php file to do so.

Replace this:
$this->someMethod();
With this:
$model = $this->getModel(); $model->someMethod();

Below, we’ve created a screenshot that shows the getModel method being used:

getModel method in action

Was this article helpful? Join the conversation!

Questions about our MailChannels Deployment? We have answers and are here to help!Learn More
+