I am trying to use multiple models in my view. My view is a single items and the models are lists displayed within the view using tabs.
in my controller I added the setModel in the display function
class ComplianceControllerCompliance extends JControllerForm
{
public function display( $cachable = false, $urlparam = array() )
{
$view = $this->getView( 'myview', 'html' );
$view->setModel( $this->getModel( 'mymodel' ), true );
$view->setModel( $this->getModel( 'content' ) );
$view->display();
}
In my view I try to access the needed information like this
$this->content_items = $this->get( 'Items', 'content' );
$this->content_pagination = $this->get( 'Pagination', 'content' );
$this->content_state = $this->get( 'State', 'content' );
but I dont get any information.
What am I doing wrong?
The basis of working with multiple models is finding a way to get an instance of each model. The most likely issue is that $this->getModel('yourmodelname')
returns false.
Test that this part works:
$testModel = $this->getModel('yourmodelname');
var_dump($testModel);
I guess you have already studied the Using multiple models in an MVC component article.