API16:JControllerForm/add
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Method to add a new record.
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
add()
Defined in
libraries/joomla/application/component/controllerform.php
Importing
jimport( 'joomla.application.component.controllerform' );
Source Body
public function add() { // Initialise variables. $app = JFactory::getApplication(); $context = "$this->_option.edit.$this->_context"; $tmpl = JRequest::getString('tmpl'); $layout = JRequest::getString('layout', 'edit'); $append = ''; // Setup redirect info. if ($tmpl) { $append .= '&tmpl='.$tmpl; } if ($layout) { $append .= '&layout='.$layout; } // Access check. if (!$this->_allowAdd()) { $this->setRedirect(JRoute::_('index.php?option='.$this->_option.'&view='.$this->_view_items, false)); return JError::raiseWarning(403, 'JError_Core_Create_not_permitted.'); } // Clear the record edit information from the session. $app->setUserState($context.'.id', null); $app->setUserState($context.'.data', null); // Redirect to the edit screen. $this->setRedirect(JRoute::_('index.php?option='.$this->_option.'&view='.$this->_view_item.$append, false)); }
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
<CodeExamplesForm />
