API16

JForm/loadFieldType

From Joomla! Documentation

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.

Syntax

$new Flag to toggle whether we should get a new instance of the object.

Returns

mixed Field object on success, false otherwise.

Defined in

libraries/joomla/form/form.php

Importing

jimport('joomla.form.form');

Source Body

publicfunctionloadFieldType($type,$new=true){$key=md5($type);$class='JFormField'.ucfirst($type);// Return the field object if it already exists and we don't need a new one.if(isset($this->_fieldTypes[$key])&&$new===false){return$this->_fieldTypes[$key];}if(!class_exists('JFormField')){jimport('joomla.form.formfield');}if(!class_exists('JFormFieldList')){require_oncedirname(__FILE__).'/fields/list.php';}if(!class_exists($class)){$paths=self::addFieldPath();// If the type is complex, add the base type to the paths.if($pos=strpos($type,'_')){// Add the complex type prefix to the paths.for($i=0,$n=count($paths);$i<$n;$i++){// Derive the new path.$path=$paths[$i].DS.strtolower(substr($type,0,$pos));// If the path does not exist, add it.if(!in_array($path,$paths)){array_unshift($paths,$path);}}// Break off the end of the complex type.$type=substr($type,$pos+1);}// Try to find the field file.jimport('joomla.filesystem.path');if($file=JPath::find($paths,strtolower($type).'.php')){require_once$file;}else{returnfalse;}// Check once and for all if the class exists.if(!class_exists($class)){returnfalse;}}// Instantiate a new field object.$this->_fieldTypes[$key]=new$class($this);return$this->_fieldTypes[$key];}

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

Examples

Code Examples

Content is available under Joomla! EDL unless otherwise noted.Joomla!® is a registered trademark of Open Source Matters, Inc.If you are experiencing technical issues with this website, please report it.
Notice a content problem? Create an account and fix it.