API16

JForm/getInstance: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Method to get an instance of a form. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</...
 
m preparing for archive only
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
Method to get an instance of a form.
Method to get an instance of a form.


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JForm/getInstance|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JForm/getInstance}}
 
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 73: Line 71:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JForm/getInstance|Edit See Also]]<nowiki>]</nowiki>
<! removed transcluded page call, red link never existed >
</span>
{{SeeAlso:JForm/getInstance}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=getInstance
  category=getInstance
  category=JForm
  category=JForm
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API16]]

Latest revision as of 01:41, 25 March 2017

Description

Method to get an instance of a form.


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

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];
}


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

Examples

Code Examples