API15:JControllerForm/cancel
From Joomla! Documentation
Description
Method to cancel an edit
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
cancel()
Defined in
libraries/joomla/application/component/controllerform.php
Importing
jimport( 'joomla.application.component.controllerform' );
Source Body
public function cancel()
{
JRequest::checkToken() or jexit(JText::_('JInvalid_Token'));
// Initialise variables.
$app = JFactory::getApplication();
$model = &$this->getModel();
$table = $model->getTable();
$checkin = property_exists($table, 'checked_out');
$context = "$this->_option.edit.$this->_context";
// Get the record id.
$recordId = (int) $app->getUserState($context.'.id');
// Attempt to check-in the current record.
if ($checkin && $recordId)
{
if(!$model->checkin($recordId))
{
// Check-in failed, go back to the record and display a notice.
$message = JText::sprintf('JError_Checkin_failed', $model->getError());
$this->setRedirect('index.php?option='.$this->_option.'&view='.$this->_view_item.'&layout=edit', $message, 'error');
return false;
}
}
// Clean the session data and redirect.
$app->setUserState($context.'.id', null);
$app->setUserState($context.'.data', null);
$this->setRedirect(JRoute::_('index.php?option='.$this->_option.'&view='.$this->_view_list, false));
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
Code Examples