while developing a MVC Component, I'm faced with the following problem: Before saving the posted data from the default.php, some data should be revised, if necessary. From what I know so far, the protected Function prepareTable(&$table) in the specific Model should cover my need. I started with a very simple approach, as follows:
protected function prepareTable(&$table){
$table=$this->getTable();
$table->image="HelloWorld";
}
My expectation is, that after submitting the template a specific field in my table has now the value "HelloWorld", but it isn't.
Perhaps, someone could give me an advice how to handle the prepareTable() function?
Thank you
If everything else is setup correctly the
prepareTable(&$table)
method already has the table object passed into it.Generally a
prepareTable()
in your class wouldn'tgetTable()
, as you replace the$table
being passed in which already has the row data bound to it. By replacing it you effectively decouple from the work already done.I would remove that line your method looks like:
If you look at the simplest implementation of
prepareTable()
in the Joomla core files, incom_banners
you will see something very similar to your method;