From Joomla! Documentation

< API16:JForm

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.


Method to get an instance of a form.

<! removed transcluded page call, red link never existed >


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.


object A instance.

Defined in



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.

                // Load the data.
                if ($file) {
                        $instances[$name]->load($data, true, true);
                } else {
                        $instances[$name]->load($data, false, true);


        return $instances[$name];

<! removed transcluded page call, red link never existed >


Code Examples