class FormController extends BaseController

Controller tailored to suit most form-based admin operations.

Methods

static  void
addModelPath( mixed $path, string $prefix = '')

Adds to the stack of model paths in LIFO order.

static  JControllerLegacy
getInstance( string $prefix, array $config = array())

Method to get a singleton controller instance.

__construct( array $config = array())

Constructor.

JControllerLegacy
addViewPath( mixed $path)

Add one or more view paths to the controller's stack, in LIFO order.

boolean
authorise( string $task)

Authorisation check

JControllerLegacy
display( boolean $cachable = false, array $urlparams = array())

Typical view method for MVC based architecture

mixed
execute( string $task)

Execute a task by triggering a method in the derived class.

JModelLegacy|boolean
getModel( string $name = '', string $prefix = '', array $config = array('ignore_request' => true))

Method to get a model object, loading it if required.

string
getName()

Method to get the controller name

string
getTask()

Get the last task that is being performed or was most recently performed.

array
getTasks()

Gets the available tasks in the controller.

JViewLegacy
getView( string $name = '', string $type = '', string $prefix = '', array $config = array())

Method to get a reference to the current view and load it if necessary.

boolean
redirect()

Redirects the browser or returns false if no redirect is set.

JControllerLegacy
registerDefaultTask( string $method)

Register the default task to perform if a mapping is not found.

JControllerLegacy
registerTask( string $task, string $method)

Register (map) a task to a method in the class.

JControllerLegacy
unregisterTask( string $task)

Unregister (unmap) a task in the class.

string
setMessage( string $text, string $type = 'message')

Sets the internal message that is passed with a redirect

boolean
checkToken( string $method = 'post', boolean $redirect = true)

Checks for a form token in the request.

JControllerLegacy
setRedirect( string $url, string $msg = null, string $type = null)

Set a URL for browser redirection.

boolean
add()

Method to add a new record.

boolean
batch( JModelLegacy $model)

Method to run batch operations.

boolean
cancel( string $key = null)

Method to cancel an edit.

boolean
edit( string $key = null, string $urlVar = null)

Method to edit an existing record.

mixed
loadhistory()

Method to load a row from version history

boolean
save( string $key = null, string $urlVar = null)

Method to save a record.

void
reload( string $key = null, string $urlVar = null)

Method to reload a record.

void
editAssociations()

Load item to edit associations in com_associations

Details

static void addModelPath( mixed $path, string $prefix = '')

Adds to the stack of model paths in LIFO order.

Parameters

mixed $path The directory (string), or list of directories (array) to add.
string $prefix A prefix for models

Return Value

void

static JControllerLegacy getInstance( string $prefix, array $config = array())

Method to get a singleton controller instance.

Parameters

string $prefix The prefix for the controller.
array $config An array of optional constructor options.

Return Value

JControllerLegacy

Exceptions

Exception if the controller cannot be loaded.

__construct( array $config = array())

Constructor.

Parameters

array $config An optional associative array of configuration settings. Recognized key values include 'name', 'defaulttask', 'modelpath', and 'view_path' (this list is not meant to be comprehensive).

Exceptions

Exception

See also

\JControllerLegacy

JControllerLegacy addViewPath( mixed $path)

Add one or more view paths to the controller's stack, in LIFO order.

Parameters

mixed $path The directory (string) or list of directories (array) to add.

Return Value

JControllerLegacy This object to support chaining.

boolean authorise( string $task)

Authorisation check

Parameters

string $task The ACO Section Value to check access on.

Return Value

boolean True if authorised

JControllerLegacy display( boolean $cachable = false, array $urlparams = array())

Typical view method for MVC based architecture

This function is provide as a default implementation, in most cases you will need to override it in your own controllers.

Parameters

boolean $cachable If true, the view output will be cached
array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link \JFilterInput::clean()}.

Return Value

JControllerLegacy A \JControllerLegacy object to support chaining.

mixed execute( string $task)

Execute a task by triggering a method in the derived class.

Parameters

string $task The task to perform. If no matching task is found, the '__default' task is executed, if defined.

Return Value

mixed The value returned by the called method.

Exceptions

Exception

JModelLegacy|boolean getModel( string $name = '', string $prefix = '', array $config = array('ignore_request' => true))

Method to get a model object, loading it if required.

Parameters

string $name The model name. Optional.
string $prefix The class prefix. Optional.
array $config Configuration array for model. Optional.

Return Value

JModelLegacy|boolean Model object on success; otherwise false on failure.

string getName()

Method to get the controller name

The dispatcher name is set by default parsed using the classname, or it can be set by passing a $config['name'] in the class constructor

Return Value

string The name of the dispatcher

Exceptions

Exception

string getTask()

Get the last task that is being performed or was most recently performed.

Return Value

string The task that is being performed or was most recently performed.

array getTasks()

Gets the available tasks in the controller.

Return Value

array Array[i] of task names.

JViewLegacy getView( string $name = '', string $type = '', string $prefix = '', array $config = array())

Method to get a reference to the current view and load it if necessary.

Parameters

string $name The view name. Optional, defaults to the controller name.
string $type The view type. Optional.
string $prefix The class prefix. Optional.
array $config Configuration array for view. Optional.

Return Value

JViewLegacy Reference to the view or an error.

Exceptions

Exception

boolean redirect()

Redirects the browser or returns false if no redirect is set.

Return Value

boolean False if no redirect exists.

JControllerLegacy registerDefaultTask( string $method)

Register the default task to perform if a mapping is not found.

Parameters

string $method The name of the method in the derived class to perform if a named task is not found.

Return Value

JControllerLegacy A \JControllerLegacy object to support chaining.

JControllerLegacy registerTask( string $task, string $method)

Register (map) a task to a method in the class.

Parameters

string $task The task.
string $method The name of the method in the derived class to perform for this task.

Return Value

JControllerLegacy A \JControllerLegacy object to support chaining.

JControllerLegacy unregisterTask( string $task)

Unregister (unmap) a task in the class.

Parameters

string $task The task.

Return Value

JControllerLegacy This object to support chaining.

string setMessage( string $text, string $type = 'message')

Sets the internal message that is passed with a redirect

Parameters

string $text Message to display on redirect.
string $type Message type. Optional, defaults to 'message'.

Return Value

string Previous message

boolean checkToken( string $method = 'post', boolean $redirect = true)

Checks for a form token in the request.

Use in conjunction with \JHtml::_('form.token') or \JSession::getFormToken.

Parameters

string $method The request method in which to look for the token key.
boolean $redirect Whether to implicitly redirect user to the referrer page on failure or simply return false.

Return Value

boolean True if found and valid, otherwise return false or redirect to referrer page.

See also

\JSession::checkToken()

JControllerLegacy setRedirect( string $url, string $msg = null, string $type = null)

Set a URL for browser redirection.

Parameters

string $url URL to redirect to.
string $msg Message to display on redirect. Optional, defaults to value set internally by controller, if any.
string $type Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage.

Return Value

JControllerLegacy This object to support chaining.

boolean add()

Method to add a new record.

Return Value

boolean True if the record can be added, false if not.

boolean batch( JModelLegacy $model)

Method to run batch operations.

Parameters

JModelLegacy $model The model of the component being processed.

Return Value

boolean True if successful, false otherwise and internal error is set.

boolean cancel( string $key = null)

Method to cancel an edit.

Parameters

string $key The name of the primary key of the URL variable.

Return Value

boolean True if access level checks pass, false otherwise.

boolean edit( string $key = null, string $urlVar = null)

Method to edit an existing record.

Parameters

string $key The name of the primary key of the URL variable.
string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).

Return Value

boolean True if access level check and checkout passes, false otherwise.

mixed loadhistory()

Method to load a row from version history

Return Value

mixed True if the record can be added, an error object if not.

boolean save( string $key = null, string $urlVar = null)

Method to save a record.

Parameters

string $key The name of the primary key of the URL variable.
string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).

Return Value

boolean True if successful, false otherwise.

void reload( string $key = null, string $urlVar = null)

Method to reload a record.

Parameters

string $key The name of the primary key of the URL variable.
string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).

Return Value

void

void editAssociations()

Load item to edit associations in com_associations

Return Value

void