Saving on the front end runs into problems while using SEF. The "id" of the row seems to be removed by the router so Joomla thinks editing a row is a new record.
I am trying to use the methods used in com_content on the front end. My problem is that when a row says it is "saved" by the message "Item successfully saved" it is really not saved to the db at all. A new record does get saved correctly.
Here's what I've done:
in the link to edit page:
<a href="<?php echo JRoute::_('index.php?option=com_biblestudy&view=message&layout=form&task=message.edit&a_id=' . (int) $item->id); ?>">
(So I use a-id for the id)
Then in the controller for the edit form:
public function edit($key = null, $urlVar = 'a_id')
{
$result = parent::edit($key, $urlVar);
return $result;
}
public function save($key = null, $urlVar = 'a_id')
{
$result = parent::save($key, $urlVar);
return $result;
}
And in the model:
protected function populateState() {
$app = JFactory::getApplication('site');
// Adjust the context to support modal layouts.
if ($layout = JRequest::getVar('layout')) {
$this->context .= '.' . $layout;
}
// Load state from the request. We use a_id to avoid collisions with the router
$pks = JRequest::getInt('a_id');
if ($pks) {
$this->pks = $pks;
}
$this->setState('
message.id', $pks);
}
public function save($data) {
$pks = JRequest::getInt('a_id');
if ($pks) {
$this->setTopics($pks, $data);
return true;
} elseif (parent::save($data)) {
$this->setTopics(JRequest::getInt('a_id'), $data);
return true;
}
}
What am I missing? The row is not saved to the database.
Thanks!
Tom