I am creating one component for Joomla back-end.

Here In edit view I have to display the value of an existing record. For that Joomla uses $data = $this->getItem(); calling the getItem function from the model file, but my records will save in more than one table.

So at the time of edit of the record how I display the data which will be stored in another table?

3 Answers 3


From my point of view and my experience you should create JTable class that will be responsible for storing and pulling data to/form DB.

But this is basically what and where, and not how. So referring to your question and answer how to display and how to store:

To display: Just use query that will gather all additional data to item property, for example to $item->subset which will be array or stdObject (that's up to you to decide) and $item itself will contain primary table data.

To store: Use same approach: form should contain fields with names like jform[subset][field1] so at JTable you'll get whole subset like $form = JFactory::getApplication()->input->get('jform',array(),'ARRAY'); $subset = $form['subset'] and will save it to any table you want.


I'm not sure that I fully understand your question. However, you can either write a SQL query that handles data from multiple tables or create JTables and associated models for the data (MVC).

This link may help you with your question:



This may not be the 'correct' solution but what I did was

To get information from other tables: In the views model, call the getItem function. Then first call the parent, then you can add to the $item object in the rest of the function. Then return the $item.

    public function getItem($pk = null) {
        $item = parent::getItem($pk);

        // Your code
        // Example
        $item->newValue = $newValueFromOtherTable

        return $item;

Then in the same model file, override the save function, run queries storing data into tables other than the views table. Finally run the parent save function to run the normal save method.

public function save($data){
  $itemId = $data['id'];
  $newValue = $data['newValue'];

// Run queries to store data from other tables in their respective tables

parent::save($data) // To run the save function

There is some room for errors in the save function but this is the only way I've been able to achieve this so far. If you run checks before storing any data however it should not cause any problems for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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