1

I write a small component to export data from a shop component, this is my first component, i get the error "Fatal error: Call to a member function getKeyName() on a non-object PATH\legacy\model\admin.php on line 885", i found some solution, but my problem is i don't wont new table, and my question is how can i avoid new sql table? Because i work with tables of already existing components and they are not edited with my component.

My sources:

http://forum.joomla.org/viewtopic.php?f=620&t=666986
http://stackoverflow.com/questions/21156707/fatal-error-call-to-a-member-function-getkeyname
http://stackoverflow.com/questions/12313272/error-call-to-a-member-function-getkeyname-component-for-joomla-2-5

I understand from this solution that i need a new table, but i don't need it...

  • Please can you show us some code? – Lodder Oct 25 '14 at 9:32
  • Here is my model file: pastebin.com/6HG7qvDS, and my form file is: pastebin.com/U51WT5Xs – jExchange Oct 25 '14 at 9:49
  • Your pastes disappeared. Also are you perhaps using something other then JModelLegacy? If its list or item I think it "assumes" there is a table attached. – Jordan Ramstad Oct 25 '14 at 11:18
  • @JordanRamstad no, i use JModelAdmin, i published files again: pastebin.com/Ev3P9f3v & pastebin.com/w18EbFPj – jExchange Oct 25 '14 at 18:46
  • What function is running for line 885 of legacy/model/admin.php? I'm guessing that is the save method, which then raises the question, how are you saving date if not to a table?! – David Fritsch Oct 26 '14 at 3:18
4

JForm usually maps to the columns of a database table when used with JModelAdmin, so if the name of a column is add it looks for add to be a column in that table.

If you look into the content component (articles) and inspect some of the form fields, then look at the database table for content you will see their names match. If you want to use JForm the best way is to apply your own logic to it, so use JModelLegacy with a controller to catch and direct save to your own model function, rather then the default.

For pretty much every function in JModelAdmin it adds $table = $this->getTable(); to be able to pass or retrieve the data from the table. However with JModelLegacy there is no direct connection to JForm but by the sounds of it you just want the clean way to display the forms, so it is probably best to just add that logic to your view class anyway (the view.html.php)

However you could override the save/retrieve functions of JModelAdmin to make use of it, but all in all it might be more work then just using JModelLegacy in my opinion. It forces less on you and gives you the ability to customize your code more if you are not using the typical Joomla way of using tables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.