Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JToolBarHelper :: DeleteList - Does not work

Tags:

joomla2.5

I created a Joomla 2.5 custom component and load data to grid on administrator side. All data loaded and adding and editing work well. But deleting is not working. It gives following error.

Fatal error: Call to a member function delete() on a non-object in 
C:\wamp\www\Joomla\libraries\joomla\application\component\controlleradmin.php on line 131

In view class I used JToolBarHelper for delete action as follows.

JToolBarHelper::deleteList('', 'regions.delete', 'JTOOLBAR_DELETE'); 
like image 508
Janith Widarshana Avatar asked Feb 16 '23 23:02

Janith Widarshana


1 Answers

I had this problem myself, and I've just figured it out. Look into your file corresponding to admin/controllers/helloworlds.php, there should be this line:

public function getModel($name = 'HelloWorld', $prefix = 'HelloWorldModel')

The first param's default value is the name of a single item (in your case, probably Region) and the second one contains the name of the component. So it should be:

public function getModel($name = 'Region', $prefix = 'NameOfYourComponentModel')

I hope this helps also in your case. In the HelloWorld example, they use HelloWorld all over the code, both as the name of the component and the main view, so it's sometimes hard to distinguish which one is what.

like image 197
PiotrK Avatar answered May 02 '23 19:05

PiotrK