How do I pass properly the models data to the view from controller in joomla 3.1. On start I initialize one of my sub controllers method to gather data on item which should fill up my form layout. Is accessed with the following url ?option=com_unis&task=unis.edit&layout=edit&id=1
than my controllers method looks like
public function edit()
{
$input = JFactory::getApplication()->input;
$model = $this->getModel ( 'item');
$view = $this->getView('item', 'html');
$view->setModel($model);
$view->setLayout('edit');
// Display the view
$view->display();
return $this;
}
than if I try to access the model in my view is returning null
Found it! But maybe is not the best workaround
in the view I init my model like
$model = $this->getModel('mymodel');
$data = $model->my_method($args);
than associate to the layout with a public variable
$this->data = $data;
After all I found out the workaround. In the view I call my model as it follows
$model = $this->getModel('mymodel');
$data = $model->my_method($args);
than I created a public variable which holds the layout data
$this->data = $data;