Thank you very much @Viper that seems to have got the model correctly.
/**
* Method to check out an item for editing and redirect to the edit form.
*
* @return void
*
* @since 1.0.0
*
* @throws Exception
*/
public function edit()
{
$app = Factory::getApplication('com_bcc_maccs_trader_application');
// Get the previous edit id (if any) and the current edit id.
$previousId = (int) $app->getUserState('
com_bcc_maccs_trader_application.edit.personaldetail.id');
$editId = $app->input->getInt('id', 0);
Factory::getApplication()->enqueueMessage('maccsaccountcasecontroller Previous editId - '.$previousId, 'notice');
Factory::getApplication()->enqueueMessage('maccsaccountcasecontroller editId - '.$editId, 'notice');
// Set the user id for the user to edit in the session.
$app->setUserState('
com_bcc_maccs_trader_application.edit.personaldetail.id', $editId);
// Get the model.
// $model = $this->getModel('Maccsaccountcase', 'Site'); - Paul this is the old one
$model = Factory::getApplication()->bootComponent('com_bcc_maccs_trader_application')->getMVCFactory()->createModel('Personaldetail', 'Site');
Factory::getApplication()->enqueueMessage('Model - Personaldetail', 'notice');
// Check out the item
if ($editId)
{
$model->checkout($editId);
}
// Check in the previous user.
if ($previousId && $previousId !== $editId)
{
$model->checkin($previousId);
}
// Redirect to the edit screen.
$this->setRedirect(Route::_('index.php?option=com_bcc_maccs_account_case&view=maccsaccountcaseform&layout=edit', false));
}
But still not populating the form :(
I assume I have to get the table as well?
This opens a whole new can of worms.
How do I get the table?
I take it in the form model ?
There is this method.
/**
* Method to get the table
*
* @param string $type Name of the Table class
* @param string $prefix Optional prefix for the table class name
* @param array $config Optional configuration array for Table object
*
* @return Table|boolean Table if found, boolean false on failure
*/
public function getTable($type = 'Personaldetail', $prefix = 'Administrator', $config = array())
{
return parent::getTable($type, $prefix, $config);
}
However, trying to get Personaldetail table results in :
Compile Error: Cannot declare class Birminghamcitycouncil\Component\Bcc_maccs_trader_application\Administrator\Table\AccountPersonaldetailTable, because the name is already in use.
Thanks - Paul