API15

JControllerForm/add: Difference between revisions

From Joomla! Documentation

m removing red link to edit, no existant pages
m preparing for archive only
 
Line 47: Line 47:


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=add
  category=add
  category=JControllerForm
  category=JControllerForm
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*

Latest revision as of 00:25, 25 March 2017

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";

        // 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.'&layout=edit', false));
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

Code Examples