Actions

API16

Difference between revisions of "JForm/load"

From Joomla! Documentation

< API16:JForm
(New page: ===Description=== Method to load the form description from a file or string. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JForm/load|Edit Descript...)
 
m (removing red link to edit, no existant pages)
 
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JForm/load|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JForm/load}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 87: Line 87:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JForm/load|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JForm/load}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 102: Line 102:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Latest revision as of 21:53, 13 May 2013

Replacement filing cabinet.png
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 load the form description from a file or string.

[<! removed edit link to red link >]

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

Syntax

load($data, $file=true, $reset=true)
Parameter Name Default Value Description
$data $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.
$reset true $reset Flag to toggle whether the form description should be reset.

Returns

boolean True on success, false otherwise.

Defined in

libraries/joomla/form/form.php

Importing

jimport( 'joomla.form.form' );

Source Body

public function load($data, $file = true, $reset = true)
{
        $return = false;
 
        // Make sure we have data.
        if (!empty($data)) {
                // If the data is a file, load the XML from the file.
                if ($file) {
                        // If we were not given the absolute path of a form file, attempt to find one.
                        if (!is_file($data)) {
                                jimport('joomla.filesystem.path');
                                $data = JPath::find(self::addFormPath(), strtolower($data).'.xml');
                                if (!$data) {
                                        return false;
                                }
                        }
 
                        // Attempt to load the XML file.
                        $xml = JFactory::getXML($data);
                }
                // Load the data as a string.
                else {
                        $xml = JFactory::getXML($data, false);
                }
                // Make sure the XML was loaded.
                if ($xml) {
                        // Check if any groups exist.
                        if (isset($xml->fields)) {
                                // Load the form groups.
                                foreach ($xml->fields as $group) {
                                        $this->loadFieldsXML($group, $reset);
                                        $return = true;
                                }
                        }
 
                        // Check if a name is set.
                        if ((string)$xml->attributes()->name && $reset) {
                                $this->setName((string)$xml->attributes()->name);
                        }
                }
        }
 
        return $return;
}

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

Examples

<CodeExamplesForm />