I would like to save user-inputs (Form with multiple text-fields) from the frontend of my component using (admin-) JTable. In this case I would like to save a new comment to the database.

I guess I could do it in the controller (overwrite the save-method) but I guess it would be better if I'd use the model and overwrite the save-method.

Is there any example how to do that?

Best regards :-)

  • The controller would be the proper place to override an existing action. Controllers are your setters, models are your getters if that helps you out in the future. You actions (db saves, redirects, etc.) should always take place in a controller.
    – Terry Carter
    Commented Apr 26, 2016 at 23:49
  • So I would overwrite the save-Method in my controller and call the JTable, right?
    – MyFault
    Commented Apr 27, 2016 at 13:14

1 Answer 1


Let me explain how joomla works imo.

Controllers are for creating / executing route and calling model for some work.

In controller you have method called save but it's preprocess $_POST aka $data and pass it to model, $controller->getModel()->save().

For me it's better to call model and pass data and use multiple JTable, it's better for further use and lil' bit of joomla and MVC style.

So in model you can do:

$return = parent::save($data);
if($return) {
    // do something with other post data 
    // JFactory::getApplication()->input->get('jform', array(), 'array);

return $return; // ofc if code in statement was good too :-)

now do your work, i dare you! ]:->

  • Hello, I'm working with your method. One question: In frontend I can not use JControllerForm - so I have to create a save-function which calls $this->getModel()->save(); . This works fine - but is it the best way? How can I automatically get $data without calling Factory::getApplication()->input...?
    – MyFault
    Commented May 4, 2016 at 14:13
  • You need to extend administrator model and view and thats all.
    – Lanah
    Commented May 4, 2016 at 14:20
  • Hi, I extend my model from JModelAdmin now - but the views are always extended from JViewLegacy...? Well, the model seems to work but the controller does not accept a "save"-method if I do not declare it.
    – MyFault
    Commented May 4, 2016 at 14:44
  • You need to extend JControllerForm controller in front and add getModel method into it.
    – Lanah
    Commented May 5, 2016 at 5:24
  • Hello, I added the getModel-Method to my JControllerForm and changed my model to extend from JModelAdmin. If I do not explicitly add the save-method to my controller and trigger $this->getModel()->save($data); the save-Method of the controller is not called.
    – MyFault
    Commented May 6, 2016 at 10:00

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.