API16:JForm/getInstance
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 get an instance of a form.
Syntax
static getInstance($data, $name= 'form', $file=true, $options=array())
| Parameter Name | Default Value | Description |
|---|---|---|
| $data | $name The name of the form. | |
| $name | 'form' | $data The name of an XML file or an XML string. |
| $file | true | $file Flag to toggle whether the $data is a file path or a string. |
| $options | array() | $options An array of options to pass to the form. |
Returns
object A instance.
Defined in
libraries/joomla/form/form.php
Importing
jimport( 'joomla.form.form' );
Source Body
public static function getInstance($data, $name = 'form', $file = true, $options = array()) { static $instances; if ($instances == null) { $instances = array(); } // Only load the form once. if (!isset($instances[$name])) { // Instantiate the form. $instances[$name] = new JForm($options); // Set the form name. $instances[$name]->setName($name); // Load the data. if ($file) { $instances[$name]->load($data, true, true); } else { $instances[$name]->load($data, false, true); } } return $instances[$name]; }
[Edit See Also] SeeAlso:JForm/getInstance
Examples
<CodeExamplesForm />
