<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Robbiej</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Robbiej"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Robbiej"/>
	<updated>2026-06-13T01:59:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Categories_and_CategoryNodes_API_Guide&amp;diff=1033492</id>
		<title>Categories and CategoryNodes API Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Categories_and_CategoryNodes_API_Guide&amp;diff=1033492"/>
		<updated>2024-11-27T15:20:31Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to the [https://manual.joomla.org/docs/general-concepts/categories/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
{{version/tutor|3.x}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The Joomla Categories and CategoryNode APIs enable you to access details of Joomla categories. The diagram below illustrates how the Joomla category classes relate to the database structures. &lt;br /&gt;
&lt;br /&gt;
[[File:Categories.jpg|right|Categories diagram]] &lt;br /&gt;
&lt;br /&gt;
The Joomla Categories table is split into &amp;quot;partitions&amp;quot;, one partition for each component which uses categories. (Here &amp;quot;partitions&amp;quot; is used in a loose sense, not related to the technical term &amp;quot;database partition&amp;quot; for example). Within each partition the category records are held within a tree structure, but always associated with the same component – for example, you can&#039;t have a com_content category which has as a parent a com_contact category. At the root of the tree is a single system root node, which is the parent of all the top-level category records of the components.&lt;br /&gt;
&lt;br /&gt;
Each component record which is associated with a category holds the id of the category record (as a foreign key), with all the category attributes being held in the category record within the Categories table. (Shown in the diagram using the example of com_contact). &lt;br /&gt;
&lt;br /&gt;
There are 2 Joomla classes (shown in yellow) which provide APIs for accessing category data:&lt;br /&gt;
# Categories – This relates to the partition within the Categories table. You must first of all specify which partition you want to access by creating a Categories object and passing the name of the component as a parameter to the constructor.&lt;br /&gt;
# CategoryNode – This relates to an individual Category record. Once you have the Categories object you can get access to the CategoryNode objects within that partition.&lt;br /&gt;
&lt;br /&gt;
In your code you can access the category data for several components, through creating several Categories instances, one for each component/partition.  &lt;br /&gt;
&lt;br /&gt;
== Categories ==&lt;br /&gt;
To get access to the set of categories for com_content use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
use Joomla\CMS\Categories\Categories;&lt;br /&gt;
$extension = &amp;quot;content&amp;quot;;&lt;br /&gt;
$categories = Categories::getInstance($extension);&lt;br /&gt;
// The above replaces the older format $categories = JCategories::getInstance($extension);&lt;br /&gt;
$categoryNodes = $categories-&amp;gt;get(12);   // returns the category node for category with id=12&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you don&#039;t have the usual &amp;quot;com_&amp;quot; prefix in the extension. &lt;br /&gt;
&lt;br /&gt;
You can provide an associative array of options as a second parameter to the Categories static &amp;lt;tt&amp;gt;getInstance()&amp;lt;/tt&amp;gt; method. The keys of this array are:&lt;br /&gt;
* &amp;quot;access&amp;quot; – if this is true (or some value which equates to PHP true) then only categories which the current user has access to view will be returned. If false then all categories will be returned, regardless of whether the current user has access to view them or not. The default is true.&lt;br /&gt;
* &amp;quot;published&amp;quot; – if this is 1 (integer one) then only categories which have a published state of 1 (ie &#039;published&#039;) will be returned. Otherwise categories of any state will be returned. The default is 1, meaning that only &#039;published&#039; categories will be returned.&lt;br /&gt;
* &amp;quot;countitems&amp;quot; – if this is 1 (integer one) then when categories are returned Joomla will determine for each category record how many of the extension records are associated with that category (the default is not to count the items). To do this, Joomla will do a SQL JOIN with the extension table, WHERE the category id field in that table matches, and COUNTing the instances of a &amp;quot;key&amp;quot; field in that table. Joomla needs to know what these tables and fields are called, and these can be provided in the array options below.&lt;br /&gt;
* &amp;quot;table&amp;quot; – the name of the extension table. There is no default, so you must supply this if you&#039;re using &amp;quot;countitems&amp;quot;. &lt;br /&gt;
* &amp;quot;field&amp;quot; – the name of the field in the extension table which holds the category id (default &amp;quot;catid&amp;quot;)&lt;br /&gt;
* &amp;quot;key&amp;quot; – the name of the key field in the extension table over which the SQL COUNT is performed (default &#039;id&#039;).&lt;br /&gt;
* &amp;quot;statefield&amp;quot; – the name of the field in the extension table which holds the published status of the record (default &#039;state&#039;). If Joomla is returning only published categories (as determined by the &amp;quot;published&amp;quot; option described above) then it will count over just published items in the extension table as well. (Note that the equivalent is NOT done for &amp;quot;access&amp;quot; – any Access field in the extension table is ignored).&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$categories = Categories::getInstance(&amp;quot;content&amp;quot;, array(&amp;quot;access&amp;quot; =&amp;gt; false, &amp;quot;published&amp;quot; =&amp;gt; 0));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Category nodes returned will not be restricted by Access or the Published state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$categories = Categories::getInstance(&amp;quot;helloworld&amp;quot;, array(&amp;quot;countitems&amp;quot; =&amp;gt; 1, &amp;quot;table&amp;quot; =&amp;gt; &amp;quot;helloworld&amp;quot;, &amp;quot;statefield&amp;quot; =&amp;gt; &amp;quot;published&amp;quot;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Category nodes of the &amp;quot;helloworld&amp;quot; component will include the number of associated records in the &amp;quot;helloworld&amp;quot; table, where the published state is held in a field called &amp;quot;published&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The Categories &amp;lt;tt&amp;gt;get()&amp;lt;/tt&amp;gt; method takes as its first parameter the &amp;lt;tt&amp;gt;id&amp;lt;/tt&amp;gt; of the category record to be read from the database and returns to the caller the corresponding CategoryNode object. If no &amp;lt;tt&amp;gt;id&amp;lt;/tt&amp;gt; is given, then the method returns the CategoryNode object relating to the system ROOT record at the very top of the category tree in the database. &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;get()&amp;lt;/tt&amp;gt; functionality actually reads from the database all the ascendents of the requested category record up to the category root record (which enables the Category Path described below to be determined), as well as all the descendants of the requested category record. It then stores these locally so that subsequent calls to obtain data for any of those children can be served by returning the data from this cache rather than performing another query on the database.&lt;br /&gt;
&lt;br /&gt;
However, if the second parameter &amp;lt;tt&amp;gt;$forceload&amp;lt;/tt&amp;gt; is set to true, then it will service the request by querying the database again, rather than using the cached records.  &lt;br /&gt;
&lt;br /&gt;
In a multilanguage site the categories returned will be restricted to those of the current language or language * (for all). Similarly, any counting of items in the extension table will be restricted to those of the current language or language *, and Joomla will assume that the language is stored in field called &amp;quot;language&amp;quot; (you can&#039;t override what this language field is called). &lt;br /&gt;
&lt;br /&gt;
== CategoryNode Properties ==&lt;br /&gt;
&lt;br /&gt;
The object from a call to the Categories &amp;lt;tt&amp;gt;get($id)&amp;lt;/tt&amp;gt; method will be a CategoryNode object relating to the category with id &amp;lt;tt&amp;gt;$id&amp;lt;/tt&amp;gt;. If you called &amp;lt;tt&amp;gt;get()&amp;lt;/tt&amp;gt; using the default of &#039;root&#039; then you will have to make a subsequent call to &amp;lt;tt&amp;gt;getChildren()&amp;lt;/tt&amp;gt; to get an array of CategoryNode objects for the extension you want, eg:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
use Joomla\CMS\Categories\Categories;&lt;br /&gt;
use Joomla\CMS\Categories\CategoryNode;&lt;br /&gt;
&lt;br /&gt;
$categories = Categories::getInstance(&amp;quot;content&amp;quot;);&lt;br /&gt;
$rootNode = $categories-&amp;gt;get();   &lt;br /&gt;
$categoryNodes = $rootNode-&amp;gt;getChildren();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you have a CategoryNode object you can access the properties of this object as defined in the API definition, and these mostly relate closely to the category attributes visible in the Joomla admin forms. Properties where the meaning is fairly clear are not described below, but below is a list of those where the meaning may not be totally apparent.&lt;br /&gt;
&lt;br /&gt;
* asset_id – where the administrator has defined ACLs for the individual category, then this is the id of the record in the asset table where these ACLs are stored.&lt;br /&gt;
&lt;br /&gt;
* parent_id, lft, rgt, level – these fields relate to the category&#039;s position in the category tree, which is implemented using the [https://en.wikipedia.org/wiki/Nested_set_model Nested Set] model. The lft and rgt values are implemented as required by the model, the parent_id is the id of the parent record in the category table (NOT in the asset table – this is a typo in the Joomla code), and the level is 0 for the root node, 1 for those records whose parent is the root node, 2 for the next level of descendants, etc. &lt;br /&gt;
&lt;br /&gt;
* extension – this time the &amp;quot;com_&amp;quot; prefix is present&lt;br /&gt;
&lt;br /&gt;
* numitems – the number of records in the extension table which are associated with this category&lt;br /&gt;
&lt;br /&gt;
* childrennumitems – this isn&#039;t set – don&#039;t try to use it!&lt;br /&gt;
&lt;br /&gt;
* slug – this is what Joomla has traditionally displayed as part of the URL when SEF URLs are displayed. It&#039;s of the form id:alias, for example 3:uncategorised.&lt;br /&gt;
&lt;br /&gt;
* assets – this isn&#039;t set – don&#039;t try to use it!&lt;br /&gt;
&lt;br /&gt;
== CategoryNode get Methods ==&lt;br /&gt;
&lt;br /&gt;
A number of the CategoryNode get methods enable you to access other CategoryNode objects in the tree:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getChildren(boolean $recursive = false)&amp;lt;/tt&amp;gt; returns an array of the immediate children, or an array of all the descendants if &amp;lt;tt&amp;gt;$recursive = true&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getParent()&amp;lt;/tt&amp;gt; returns the parent CategoryNode&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getSibling(boolean $right = true)&amp;lt;/tt&amp;gt; returns the sibling CategoryNode to the right, or to the left if &amp;lt;tt&amp;gt;$right = false&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
A number of the get methods return properties of the CategoryNode object &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getAuthor(boolean $modified_user = false)&amp;lt;/tt&amp;gt; returns the User object associated with the user who created the category, or the user who last modified the user if &amp;lt;tt&amp;gt;$modified_user = true&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getMetadata()&amp;lt;/tt&amp;gt; returns a Joomla Registry object containing the category metadata (json structure)&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getParams()&amp;lt;/tt&amp;gt; returns a Joomla Registry object containing the category params (json structure)&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getNumItems(boolean $recursive = false)&amp;lt;/tt&amp;gt; returns the number of records in the extension table which are related to this category. If  &amp;lt;tt&amp;gt;$recursive = true&amp;lt;/tt&amp;gt; then it&#039;s the total number of records associated with this category and all of this category&#039;s descendants.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;getPath()&amp;lt;/tt&amp;gt; returns an array of the slugs going from the root of the category tree down the tree to this category. For example, if this category has id 9 and alias &amp;quot;dog&amp;quot;, it&#039;s parent has id 6 and alias &amp;quot;mammal&amp;quot;, and grandparent (immediately below the root) has id 3 and alias &amp;quot;animal&amp;quot; then &amp;lt;tt&amp;gt;getPath()&amp;lt;/tt&amp;gt; will return &amp;lt;tt&amp;gt;array(3 =&amp;gt; &amp;quot;3:animal&amp;quot;, 6 =&amp;gt; &amp;quot;6:mammal&amp;quot;, 9 =&amp;gt; &amp;quot;9:dog&amp;quot;)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Note that &amp;lt;tt&amp;gt;hasParent()&amp;lt;/tt&amp;gt; includes the parent being the root node, so that a call to this method will always return &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; unless you&#039;re calling it on the root node. &lt;br /&gt;
&lt;br /&gt;
== CategoryNode set Methods ==&lt;br /&gt;
&lt;br /&gt;
There are a number of &amp;lt;tt&amp;gt;set&amp;lt;/tt&amp;gt; methods of the CategoryNode API, but these are primarily used by the Joomla category functionality to set up the CategoryNode objects, based on data retrieved from the database. Calling one of these does not persist the data to the database, eg you can&#039;t use &amp;lt;tt&amp;gt;setParent()&amp;lt;/tt&amp;gt; to reparent a category record under a different category parent in the database. &lt;br /&gt;
&lt;br /&gt;
== Sample Module Code ==&lt;br /&gt;
&lt;br /&gt;
Below is the code for a simple Joomla module which you can install and run to demonstrate use of the Categories and CategoryNode API functionality. If you are unsure about development and installing a Joomla module then following the tutorial at [[S:MyLanguage/J3.x:Creating a simple module/Introduction| Creating a simple module ]] will help.&lt;br /&gt;
&lt;br /&gt;
In a folder mod_sample_categories create the following 2 files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;mod_sample_categories.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.1&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;Categories demo&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.1&amp;lt;/version&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Code demonstrating use of Joomla APIs related to Categories&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_sample_categories&amp;quot;&amp;gt;mod_sample_categories.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;mod_sample_categories.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted Access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
use Joomla\CMS\Categories\Categories;&lt;br /&gt;
use Joomla\CMS\Categories\CategoryNode;&lt;br /&gt;
&lt;br /&gt;
$app = Factory::getApplication();&lt;br /&gt;
$input = $app-&amp;gt;input;&lt;br /&gt;
$ext = $input-&amp;gt;get(&#039;categoryextension&#039;, &amp;quot;Content&amp;quot;, &amp;quot;STRING&amp;quot;);&lt;br /&gt;
$tab = $input-&amp;gt;get(&#039;categorytable&#039;, &amp;quot;Content&amp;quot;, &amp;quot;STRING&amp;quot;);&lt;br /&gt;
echo &amp;quot;Getting {$ext} categories and using {$tab} table&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
echo &amp;quot;-------------&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$categories = Categories::getInstance($ext, array(&amp;quot;table&amp;quot; =&amp;gt; &amp;quot;Content&amp;quot;, &amp;quot;countItems&amp;quot; =&amp;gt; 1, &amp;quot;access&amp;quot; =&amp;gt; false));&lt;br /&gt;
&lt;br /&gt;
$cat0 = $categories-&amp;gt;get(&#039;root&#039;);&lt;br /&gt;
&lt;br /&gt;
$cats = $cat0-&amp;gt;getChildren(true);&lt;br /&gt;
foreach ($cats as $cat)&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;Category {$cat-&amp;gt;id}, title: {$cat-&amp;gt;title}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	echo &amp;quot;Level: {$cat-&amp;gt;level}, parent id: {$cat-&amp;gt;parent_id}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	echo &amp;quot;Numitems {$cat-&amp;gt;getNumitems()}, including descendants: {$cat-&amp;gt;getNumitems(true)}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	var_dump($cat-&amp;gt;getPath());&lt;br /&gt;
	echo &amp;quot;-------------&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$ext2 = $input-&amp;gt;get(&#039;option&#039;, &amp;quot;&amp;quot;, &amp;quot;STRING&amp;quot;);&lt;br /&gt;
$catid = $input-&amp;gt;get(&#039;catid&#039;, 0, &amp;quot;INT&amp;quot;);&lt;br /&gt;
$view = $input-&amp;gt;get(&#039;view&#039;, &amp;quot;&amp;quot;, &amp;quot;STRING&amp;quot;);&lt;br /&gt;
$id = $input-&amp;gt;get(&#039;id&#039;, 0, &amp;quot;INT&amp;quot;);&lt;br /&gt;
if ($ext2 &amp;amp;&amp;amp; (strtolower(substr($ext2, 0, 4)) == &amp;quot;com_&amp;quot;) &amp;amp;&amp;amp; ($catid || (strtolower($view) == &amp;quot;category&amp;quot; &amp;amp;&amp;amp; $id)))&lt;br /&gt;
{&lt;br /&gt;
	$ext2 = substr($ext2, 4);&lt;br /&gt;
	$categories2 = Categories::getInstance($ext2, array(&amp;quot;access&amp;quot; =&amp;gt; false));&lt;br /&gt;
	$categoryId = $catid ? $catid : $id; &lt;br /&gt;
	echo &amp;quot;&amp;lt;br&amp;gt;Getting $ext2 category $categoryId&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	$cat2 = $categories2-&amp;gt;get($categoryId);&lt;br /&gt;
	if ($cat2)&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;Category {$cat2-&amp;gt;id}, title: {$cat2-&amp;gt;title}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Zip up the mod_sample_categories directory to create &amp;lt;tt&amp;gt;mod_sample_categories.zip&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Within your Joomla administrator go to Install Extensions and via the Upload Package File tab select this zip file to install this sample categories module.&lt;br /&gt;
&lt;br /&gt;
Make this module visible by editing it (click on it within the Modules page) then:&lt;br /&gt;
# making its status Published&lt;br /&gt;
# selecting a position on the page for it to be shown&lt;br /&gt;
# on the menu assignment tab specify the pages it should appear on&lt;br /&gt;
&lt;br /&gt;
When you visit a site web page then you should see the module in your selected position, and it should show the set of com_content categories in the database and for each category:&lt;br /&gt;
* the id and title&lt;br /&gt;
* the level in the category tree and the id of the parent&lt;br /&gt;
* the number of articles which have this category set, and the number of articles which have this category or any of the category&#039;s descendants&lt;br /&gt;
* a &amp;lt;tt&amp;gt;var_dump&amp;lt;/tt&amp;gt; of the category &amp;lt;tt&amp;gt;getPath()&amp;lt;/tt&amp;gt; return value.&lt;br /&gt;
&lt;br /&gt;
You can get categories for other components by adding the parameters &amp;lt;tt&amp;gt;categoryextension&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;categorytable&amp;lt;/tt&amp;gt; to the URL, eg &amp;lt;tt&amp;gt;...&amp;amp;categoryextension=contact&amp;amp;categorytable=contact_details&amp;lt;/tt&amp;gt; to get com_contact categories. Note that if you&#039;re trying to get the categories of a component which isn&#039;t one of the core Joomla components, then you may need to supply the component field names etc within the &amp;lt;tt&amp;gt;options&amp;lt;/tt&amp;gt; to the &amp;lt;tt&amp;gt;Categories::getInstance()&amp;lt;/tt&amp;gt; call, as described above. &lt;br /&gt;
&lt;br /&gt;
The code also tries to guess if the page displayed relates to a category, by checking if there&#039;s a &amp;lt;tt&amp;gt;catid&amp;lt;/tt&amp;gt; parameter in the URL, or if the &amp;lt;tt&amp;gt;view&amp;lt;/tt&amp;gt; parameter is set to &#039;category&#039;. In this case it shows the id and title of the associated category. Obviously this may not work correctly in all cases. &lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Module Development]]&lt;br /&gt;
[[Category:Plugin Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Menu_and_Menuitems_API_Guide&amp;diff=1033491</id>
		<title>Menu and Menuitems API Guide</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Menu_and_Menuitems_API_Guide&amp;diff=1033491"/>
		<updated>2024-11-27T11:04:48Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to the [https://manual.joomla.org/docs/general-concepts/menus-menuitems/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
{{version/tutor|3.x}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This is one of a series of [[API Guides]] to help you understand how to use the Joomla APIs through providing detailed explanations and sample code which you can easily install and run.&lt;br /&gt;
&lt;br /&gt;
In Joomla a Menu is the set of navigation links you can have as a main menu (e.g. at the top of your site) or subsidiary menu (e.g. in the footer). Each of the individual navigation links is a menu item.&lt;br /&gt;
&lt;br /&gt;
Within an overall Menu structure you can have a &amp;quot;submenu&amp;quot;. This isn&#039;t implemented as a Joomla Menu construct, rather as a set of menu items below a parent menu item. The Joomla menu items are thus implemented in an ordered tree structure, specifically using the [https://en.wikipedia.org/wiki/Nested_set_model Nested Set model].&lt;br /&gt;
&lt;br /&gt;
This guide explains the Joomla API around the Menu/Menuitem area and includes sample module code which you can install on your site as a demonstration of the capabilities.&lt;br /&gt;
&lt;br /&gt;
== Basic Operations ==&lt;br /&gt;
There isn&#039;t a Joomla API to enable you to get the set of Menus on the system, so if you really do need these then your only recourse is to read the data from the &#039;&#039;menu_types&#039;&#039; table directly using a SQL query. But you can find from the menu item structure described below the Menu to which that menu item belongs and find all the menu items for a particular Menu.&lt;br /&gt;
&lt;br /&gt;
When the Joomla application starts up in response to an HTTP request arriving at a Joomla site, it builds up a big structure containing lots of things which it realises will likely be needed during the process of working out what will be displayed on the web page. Within this structure it includes all the menu items which may be needed. To get at this structure do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
$app = Factory::getApplication();&lt;br /&gt;
$sitemenu = $app-&amp;gt;getMenu();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;$sitemenu&#039;&#039; structure will have entries for all the menu items (plus access to a lot of other information besides, but which doesn&#039;t concern us).&lt;br /&gt;
&lt;br /&gt;
To get at the individual menu items we apply a filter to &#039;&#039;$sitemenu&#039;&#039; using &#039;&#039;getItems()&#039;&#039; to select the particular menu items we&#039;re interested in. To obtain an array of all the menu items use a blank filter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$menuitems = $sitemenu-&amp;gt;getItems(array(), array());&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To obtain an array of all the menu items which are in the &amp;quot;mainmenu&amp;quot; menu use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$mainmenuItems = $sitemenu-&amp;gt;getItems(&#039;menutype&#039;, &#039;mainmenu&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above gives all the menu items within the &amp;quot;mainmenu&amp;quot; menu, including those in submenus. To access just the menu items which are in the topmost or first submenu level of the &amp;quot;mainmenu&amp;quot; menu use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$mainmenuItems = $sitemenu-&amp;gt;getItems(array(&#039;menutype&#039;,&#039;level&#039;), array(&#039;mainmenu&#039;,array(&amp;quot;1&amp;quot;,&amp;quot;2&amp;quot;)));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To filter the specific menu items you want, you pass an array of properties (from the list in the next section) and an array of corresponding values which those properties should have.&lt;br /&gt;
&lt;br /&gt;
Unpublished menu items are not returned. They&#039;re not included within the &#039;&#039;$sitemenu&#039;&#039; structure.&lt;br /&gt;
&lt;br /&gt;
Note that there isn&#039;t an equivalent method to get the menu items on the administrator back-end, as the equivalent structure to &#039;&#039;$sitemenu&#039;&#039; above isn&#039;t populated with the admin menu structure. If you wanted to access the menu details you would have to read and interpret the appropriate records from the database.&lt;br /&gt;
&lt;br /&gt;
== Properties and Parameters ==&lt;br /&gt;
&lt;br /&gt;
The following are available as public properties of the &#039;&#039;Menuitem&#039;&#039; class. Most of these are shown in the first tab (&amp;quot;Details&amp;quot;) of the &amp;quot;Menus: Edit Item&amp;quot; form when you&#039;re editing a menu item within the back end. Once you have a &#039;&#039;Menuitem&#039;&#039; object you can access the properties directly, as shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$menuitems = $sitemenu-&amp;gt;getItems(array(), array());&lt;br /&gt;
foreach ($menuitems as $menuitem)&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;Itemid: {$menuitem-&amp;gt;id}&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;id&#039;&#039;&#039; – this is the id of the menu item. In Joomla code its usually referred to as the Itemid, probably to distinguish it from the id of, for example, an article (as both often appear in URLs when not using SEF URLs)&lt;br /&gt;
* &#039;&#039;&#039;menutype&#039;&#039;&#039; – this identifies the Menu which the menu item belongs to. It&#039;s a unique identifier Menu Type which you assign to a menu&lt;br /&gt;
* &#039;&#039;&#039;title&#039;&#039;&#039; – what will be displayed when the menu item is shown on the menu (called the &amp;quot;Menu Title&amp;quot; in the form).&lt;br /&gt;
* &#039;&#039;&#039;alias&#039;&#039;&#039; – the segment of the URL when using SEF URLs&lt;br /&gt;
* &#039;&#039;&#039;note&#039;&#039;&#039; – the optional note shown on the form&lt;br /&gt;
* &#039;&#039;&#039;route&#039;&#039;&#039; – the section of the SEF URL which gets to this menu item. For example if the alias of this menu item is &amp;quot;me&amp;quot;, the alias of its parent is &amp;quot;dad&amp;quot; and of its grandparent (at the top level of the menu) is &amp;quot;gran&amp;quot; then the route returned is &amp;quot;gran/dad/me&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;link&#039;&#039;&#039; – the link shown in the Link field of the form&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; – usually this will be &amp;quot;component&amp;quot; and the link will point to component functionality in Joomla. But it may also be one of the following, when the Menu Item Type selected is one of the System Links:&lt;br /&gt;
** &#039;&#039;&#039;&amp;quot;heading&amp;quot;&#039;&#039;&#039; – Menu Heading – a heading for the parent of submenu items&lt;br /&gt;
** &#039;&#039;&#039;&amp;quot;alias&amp;quot;&#039;&#039;&#039; – Menu Item Alias – an alias to another menu item&lt;br /&gt;
** &#039;&#039;&#039;&amp;quot;separator&amp;quot;&#039;&#039;&#039; – Separator – a text string (e.g. dashes) to separate items in a menu&lt;br /&gt;
** &#039;&#039;&#039;&amp;quot;url&amp;quot;&#039;&#039;&#039; – URL – a link to an external URL.&lt;br /&gt;
* &#039;&#039;&#039;level&#039;&#039;&#039; – the level within the menu item tree. The &amp;quot;root&amp;quot; entry at the base of the tree is level &amp;quot;0&amp;quot;, menu items at the top level in a menu have level &amp;quot;1&amp;quot;, first submenu level &amp;quot;2&amp;quot;, etc.&lt;br /&gt;
* &#039;&#039;&#039;language&#039;&#039;&#039; – the language code. For example, &amp;quot;es-ES&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;browserNav&#039;&#039;&#039; – the value associated with the option entered in the Target Window field of the form. Generally this means the following;&lt;br /&gt;
** &#039;&#039;&#039; 0&#039;&#039;&#039; – Parent – the link opens in the same tab&lt;br /&gt;
** &#039;&#039;&#039;1&#039;&#039;&#039; – New Window with Navigation – the link opens in a new tab&lt;br /&gt;
** &#039;&#039;&#039;2&#039;&#039;&#039; – New Window without Navigation – the link opens in a new window&lt;br /&gt;
* &#039;&#039;&#039;access&#039;&#039;&#039; – the id of the AccessLevel assigned to this menu item. When you use this API it checks the  logged on user and returns only those menu items which this user is permitted to view.&lt;br /&gt;
* &#039;&#039;&#039;home&#039;&#039;&#039; – whether or not this is a home page (&amp;quot;Default Page&amp;quot;) for the site or language.&lt;br /&gt;
* &#039;&#039;&#039;img&#039;&#039;&#039; – this doesn&#039;t seem to be used any more. You can specify an image to be used in the menu item, but this is now specified in the Link Type tab in the form and stored in the params &amp;quot;menu_image&amp;quot; field.&lt;br /&gt;
* &#039;&#039;&#039;template_style_id&#039;&#039;&#039; – the id of the Template Style entered in the form&lt;br /&gt;
* &#039;&#039;&#039;component_id&#039;&#039;&#039; – the id of the component associated with this menu item&lt;br /&gt;
* &#039;&#039;&#039;parent_id&#039;&#039;&#039; – the id of the parent in the menu item tree&lt;br /&gt;
* &#039;&#039;&#039;component&#039;&#039;&#039; – the name of the associated component, e.g. &amp;quot;com_contact&amp;quot;&lt;br /&gt;
* &#039;&#039;&#039;tree&#039;&#039;&#039; – an array of the menu item ids getting to this menu item in the tree. If this menu item has id 789, its parent id 456 and grandparent 123, where the grandparent is on the topmost menu (ie its parent is the root node), then tree returned will be an &#039;&#039;array (&amp;quot;123&amp;quot;, &amp;quot;456&amp;quot;, &amp;quot;789&amp;quot;)&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;query&#039;&#039;&#039; – an associative array of the query parameters shown in the Link field on the form. For example for a menu item pointing to a single article this will be of the form: &#039;&#039;array(&amp;quot;option&amp;quot; =&amp;gt; &amp;quot;com_content&amp;quot;, &amp;quot;view&amp;quot; =&amp;gt; &amp;quot;article&amp;quot;, &amp;quot;id&amp;quot; =&amp;gt; &amp;quot;123&amp;quot;)&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All the other attributes of the menu item are stored in the params field in the database and accessed using the &#039;&#039;getParams()&#039;&#039; method. These are too many and varied to specify completely here. Two examples are shown below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$params = $menuitem-&amp;gt;getParams();&lt;br /&gt;
$displayed = $params-&amp;gt;get(&amp;quot;menu_show&amp;quot;);&lt;br /&gt;
$show_tags = $params-&amp;gt;get(&amp;quot;show_tags&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;$displayed&#039;&#039; variable will hold a boolean depending on whether this menu item should be shown in the menu or hidden, corresponding to the setting of the &amp;quot;Display in Menu&amp;quot; field in the Link Type tab in the form.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;$show_tags&#039;&#039; variable will hold a boolean defining whether or not to show tags associated with the item being displayed. However the presence of this field will depend on what is being presented on the web page which the menu item points to. If it&#039;s an article or contact then it&#039;s relevant and may be set, but if it&#039;s a link to a Search Form or Search Results then it isn&#039;t relevant and will not be set.&lt;br /&gt;
&lt;br /&gt;
Some of these parameters (e.g. those defined in the Link Type tab of the menu item edit form) may be defined for menu items in general, although the specific fields stored depend on the Menu Item Type selected (ie &#039;&#039;type&#039;&#039; property in the list of properties above). To find these look in the Joomla code under &#039;&#039;administrator/components/com_menus/model/form/item_???.xml&#039;&#039;, replacing ??? by the &#039;&#039;type&#039;&#039;. These xml files provide definitions of parts of the &amp;quot;Menus: Edit Item&amp;quot; form and you can find in them the name of the attribute which is stored in the params json string in the database and accessed programmatically via the &#039;&#039;getParams()-&amp;gt;get()&#039;&#039; method.&lt;br /&gt;
&lt;br /&gt;
Other parameters are related to the component which is navigated to via this menu item and contain attributes which related to how the output of that component is displayed on that particular web page. To find these locate the &#039;&#039;.xml&#039;&#039; file in the folder where the layout file for that particular page is held. For example, for a page displaying a single contact look in &#039;&#039;components/com_contact/contact/tmpl&#039;&#039;. (See the Joomla Component MVC Tutorial step [[J3.x:Developing an MVC Component/Adding a variable request in the menu type|Adding a variable request in the menu type]] for an example showing how components define the options to be shown against menu items).&lt;br /&gt;
&lt;br /&gt;
== Getting Individual Menu Iitems ==&lt;br /&gt;
&lt;br /&gt;
As well as the mechanisms described above for filtering down to the menu item(s) you want, there are some methods available to get directly to certain menu items.&lt;br /&gt;
&lt;br /&gt;
=== Active Menu Item ===&lt;br /&gt;
&lt;br /&gt;
The active menu item of a site web page relates to the menu item which Joomla is using to determine the presentation of that page (e.g. using the Template Style defined for the menu item). To find this use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
$app = Factory::getApplication();&lt;br /&gt;
$sitemenu = $app-&amp;gt;getMenu();&lt;br /&gt;
$activeMenuitem = $sitemenu-&amp;gt;getActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then get the properties and parameters of this menu item as described above.&lt;br /&gt;
&lt;br /&gt;
However, note that there are unusual cases where (in Joomla 3.x at least) the active menu item is not set. You can show this by configuring your site as described below and using the sample module code included at the end of this page which outputs the active menu item Itemid.&lt;br /&gt;
&lt;br /&gt;
Set up your site as an international site (e.g. using the multi-language installation option) and ensure you&#039;ve got the menu switcher module being displayed. Then create for example:&lt;br /&gt;
* a contact &amp;quot;John&amp;quot; with language &amp;quot;English&amp;quot;&lt;br /&gt;
* a contact &amp;quot;Jean&amp;quot; with language &amp;quot;French&amp;quot;&lt;br /&gt;
* associate together these 2 contacts via the Contact Associations feature&lt;br /&gt;
* an &amp;quot;english&amp;quot; menu which contains a menu item with language &amp;quot;English&amp;quot; pointing to the contact &amp;quot;John&amp;quot;&lt;br /&gt;
* a &amp;quot;french&amp;quot; menu but which has no menu items relating to Contacts.&lt;br /&gt;
Display on your site the English menu and click on the contact menu item to show &amp;quot;John&amp;quot;. Then click on the French flag in the menu switcher module. This should display the &amp;quot;Jean&amp;quot; contact, but have no active menu item. Joomla is displaying the French contact (as it&#039;s associated to the English one), but can find no menu item relating to contacts and so uses a default mechanism for presenting the page, but doesn&#039;t have an active menu item. In general it seems that if you use a menu item for component A but force it to present component B (by setting the &amp;quot;option&amp;quot; parameter to override the default option associated with a menu item) then the active menu item is not set.&lt;br /&gt;
&lt;br /&gt;
=== Default Menu Item ===&lt;br /&gt;
To find the default menu item for a language use for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$lang = &amp;quot;es-ES&amp;quot;;      // or $lang = &amp;quot;*&amp;quot; for all languages&lt;br /&gt;
$defaultMenuitem = $sitemenu-&amp;gt;getDefault($lang);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Menu Item from Itemid ===&lt;br /&gt;
If you wish to find the menu item associated with a specific id &#039;&#039;$itemid&#039;&#039; use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$menuitem = $sitemenu-&amp;gt;getItem($itemid);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting Menu Items ==&lt;br /&gt;
You can set menu item properties and parameters using for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$menuitem-&amp;gt;setParams($params)     //set the params values&lt;br /&gt;
&lt;br /&gt;
$sitemenu-&amp;gt;setActive($itemid)     // set the active menu item&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or by simply assigning different values to the menu item public properties. However these changes are not saved to the database and will last only for the duration of handling the current HTTP request.&lt;br /&gt;
&lt;br /&gt;
== Sample Module Code ==&lt;br /&gt;
Below is the code for a simple Joomla module which you can install and run to demonstrate use of the menu item API functionality. If you are unsure about development and installing a Joomla module then following the tutorial at [[S:MyLanguage/J3.x:Creating a simple module/Introduction| Creating a simple module ]] will help.&lt;br /&gt;
&lt;br /&gt;
In a folder mod_sample_menu create the following 2 files:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;mod_sample_menu.xml&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.1&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;Menu demo&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.1&amp;lt;/version&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Code demonstrating use of Joomla APIs related to Menus and Menu Items&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_sample_menu&amp;quot;&amp;gt;mod_sample_menu.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;mod_sample_menu.php&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted Access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
$app = Factory::getApplication();&lt;br /&gt;
$input = $app-&amp;gt;input;&lt;br /&gt;
&lt;br /&gt;
$sitemenu = $app-&amp;gt;getMenu();&lt;br /&gt;
&lt;br /&gt;
if ($activeMenuitem = $sitemenu-&amp;gt;getActive())&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;Active menuitem is Itemid: {$activeMenuitem-&amp;gt;id}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;No active menuitem&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ($input-&amp;gt;exists(&#039;menulanguage&#039;))&lt;br /&gt;
{&lt;br /&gt;
	$lang = $input-&amp;gt;get(&#039;menulanguage&#039;, &amp;quot;&amp;quot;, &amp;quot;STRING&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	$lang = Factory::getLanguage()-&amp;gt;getTag();&lt;br /&gt;
}&lt;br /&gt;
echo &amp;quot;Getting details for language {$lang}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$menuitems = $sitemenu-&amp;gt;getItems(array(&amp;quot;language&amp;quot;), array($lang));&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;&amp;lt;br&amp;gt;---- properties of menuitems ----&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
foreach ($menuitems as $menuitem)&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;&amp;lt;br&amp;gt;Itemid: {$menuitem-&amp;gt;id}, title: {$menuitem-&amp;gt;title}, type: {$menuitem-&amp;gt;type}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	echo &amp;quot;&amp;lt;br&amp;gt;Language: {$menuitem-&amp;gt;language}, level: {$menuitem-&amp;gt;level}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	$params = $menuitem-&amp;gt;getParams();&lt;br /&gt;
	if (!($displayed = $params-&amp;gt;get(&amp;quot;menu_show&amp;quot;)))&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;This menu item is hidden&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	if ($img = $params-&amp;gt;get(&amp;quot;menu_image&amp;quot;))&lt;br /&gt;
	{&lt;br /&gt;
		$imgURL = JURI::root() . $img;&lt;br /&gt;
		echo &amp;quot;Image: {$img}&amp;lt;br&amp;gt;&amp;lt;img src=&#039;{$imgURL}&#039;&amp;gt;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Zip up the mod_sample_menu directory to create &#039;&#039;mod_sample_menu.zip&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Within your Joomla administrator go to Install Extensions and via the Upload Package File tab select this zip file to install this sample menu module.&lt;br /&gt;
&lt;br /&gt;
Make this module visible by editing it (click on it within the Modules page) then:&lt;br /&gt;
# making its status Published&lt;br /&gt;
# selecting a position on the page for it to be shown&lt;br /&gt;
# on the menu assignment tab specify the pages it should appear on&lt;br /&gt;
&lt;br /&gt;
When you visit a site web page then you should see the module in your selected position and it should show&lt;br /&gt;
* the Itemid of the current active menuitem,&lt;br /&gt;
* a set of properties associated with menu items having the current language,&lt;br /&gt;
* a couple of attributes from the params (displaying if the menu item is hidden and any image associated with a menu item).&lt;br /&gt;
You can get it to display the properties and parameters for other languages by adding a URL parameter like &#039;&#039;?menulanguage=fr-FR&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Module Development]]&lt;br /&gt;
[[Category:Plugin Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Retrieving_request_data_using_JInput&amp;diff=1033490</id>
		<title>Retrieving request data using JInput</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Retrieving_request_data_using_JInput&amp;diff=1033490"/>
		<updated>2024-11-27T10:48:27Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to the [https://manual.joomla.org/docs/general-concepts/input/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
{{version|2.5,3.x|platform=11.1,12.1}}&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
The Joomla Input class (previously known as JInput class) allows you to retrieve the parameters which were sent in the HTTP request. It doesn&#039;t matter whether the parameters are HTTP GET parameters (specified in the &amp;lt;tt&amp;gt;?param=val&amp;lt;/tt&amp;gt; query part of the URL) or POST parameters (specified in the body of the HTTP request), both are accessible via the methods described here.&lt;br /&gt;
&lt;br /&gt;
You can specify a filter to be applied to the parameter value, so that what you receive back is sanitised and in the form which you expect. &lt;br /&gt;
&lt;br /&gt;
For example, if you expect a parameter p1 to be an integer, then you can apply an &amp;quot;INTEGER&amp;quot; filter when you get its value. Then if someone specifies &amp;lt;tt&amp;gt;?p1=82abc5&amp;lt;/tt&amp;gt; in the URL string you will get back the value &amp;lt;tt&amp;gt;82&amp;lt;/tt&amp;gt;. (No error is raised if the value doesn&#039;t match what you expect – you just get the result of passing the value through the filter).&lt;br /&gt;
&lt;br /&gt;
==Using JInput==&lt;br /&gt;
To use JInput you must first create an object of the Input class by using this code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
$input = Factory::getApplication()-&amp;gt;input;&lt;br /&gt;
// equivalent of the older format $input = JFactory::getApplication()-&amp;gt;input;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then to get the value of a specific parameter use&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$val = $input-&amp;gt;get(param_name, default_value, filter);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where:&lt;br /&gt;
* &amp;lt;tt&amp;gt;param_name&amp;lt;/tt&amp;gt; is a string containing the name of the parameter you want to retrieve&lt;br /&gt;
* &amp;lt;tt&amp;gt;default_value&amp;lt;/tt&amp;gt; is the value you want returned if the parameter is not found; it may be a string, integer, array, null, etc. – whatever you want.&lt;br /&gt;
* &amp;lt;tt&amp;gt;filter&amp;lt;/tt&amp;gt; is a string specifying one of the filters in the list below. If you don&#039;t specify this parameter then a default of &amp;quot;cmd&amp;quot; is used.&lt;br /&gt;
&lt;br /&gt;
As an example, the code below shows how to get the value of a parameter p1. The value of the parameter is passed through a &amp;quot;string&amp;quot; filter which will remove html tags and the like. If the parameter doesn&#039;t exist then the string &amp;quot;xxx&amp;quot; is returned. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
$app = Factory::getApplication();   // equivalent of $app = JFactory::getApplication();&lt;br /&gt;
$input = $app-&amp;gt;input;&lt;br /&gt;
$p1 = $input-&amp;gt;get(&#039;p1&#039;, &#039;xxx&#039;, &#039;string&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;JInput returns an array of filtered entries if the user input is an array. Calling the above example with ?p1[]=xxx will return $p1 as array with one element &#039;xxx&#039; filter as string.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The method &amp;lt;tt&amp;gt;exists()&amp;lt;/tt&amp;gt; can also be used to check if a parameter exists, but in practice this isn&#039;t often used, as using the &amp;lt;tt&amp;gt;default_value&amp;lt;/tt&amp;gt; parameter usually covers adequately the case when a parameter is absent. &lt;br /&gt;
&lt;br /&gt;
== Available Filters ==&lt;br /&gt;
&lt;br /&gt;
Below is a list of the available filters, together with a little explanation if appropriate, and some code which is intended to clarify what the filter is actually doing. Filters can be specified in either lower or upper case, and if 2 filters are listed on the same line below, then it indicates that they are equivalent. &lt;br /&gt;
&lt;br /&gt;
{{notice|The code fragments in the following list show the &#039;&#039;implementation&#039;&#039; of the filters (assuming the value you want to retrieve is stored in &amp;lt;code&amp;gt;$source&amp;lt;/code&amp;gt;). You do not need them to &#039;&#039;use&#039;&#039; JInput; all you need for using JInput is the code shown above.}}&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;INT&amp;quot;, &amp;quot;INTEGER&amp;quot; - returns the first integer found in the parameter value&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Only use the first integer value&lt;br /&gt;
preg_match(&#039;/-?[0-9]+/&#039;, (string) $source, $matches);&lt;br /&gt;
$result = @ (int) $matches[0];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;UINT&amp;quot; - returns an unsigned int. For example, if the parameter is specified &amp;lt;tt&amp;gt;?p1=-2&amp;lt;/tt&amp;gt; then this filter will discard the minus sign and you will get the value &amp;lt;tt&amp;gt;2&amp;lt;/tt&amp;gt; returned as the value of &amp;lt;tt&amp;gt;p1&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Only use the first integer value&lt;br /&gt;
preg_match(&#039;/-?[0-9]+/&#039;, (string) $source, $matches);&lt;br /&gt;
$result = @ abs((int) $matches[0]);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;FLOAT&amp;quot;, &amp;quot;DOUBLE&amp;quot; - returns the first float found&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Only use the first floating point value&lt;br /&gt;
preg_match(&#039;/-?[0-9]+(\.[0-9]+)?/&#039;, (string) $source, $matches);&lt;br /&gt;
$result = @ (float) $matches[0];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;BOOL&amp;quot;, &amp;quot;BOOLEAN&amp;quot; - be careful with this! If you specify in the URL &amp;lt;tt&amp;gt;?p1=false&amp;lt;/tt&amp;gt; then the value of &amp;lt;tt&amp;gt;p1&amp;lt;/tt&amp;gt; is actually the string &amp;lt;tt&amp;gt;&amp;quot;false&amp;quot;&amp;lt;/tt&amp;gt; and as this is a non-empty string &amp;lt;tt&amp;gt;(bool) p1&amp;lt;/tt&amp;gt; will return &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$result = (bool) $source;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;WORD&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Only allow characters a-z, and underscores&lt;br /&gt;
$result = (string) preg_replace(&#039;/[^A-Z_]/i&#039;, &#039;&#039;, $source);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;ALNUM&amp;quot; - alphanumeric&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Allow a-z and 0-9 only&lt;br /&gt;
$result = (string) preg_replace(&#039;/[^A-Z0-9]/i&#039;, &#039;&#039;, $source);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;CMD&amp;quot; - used often when obtaining the &amp;lt;tt&amp;gt;?option=controller.task&amp;lt;/tt&amp;gt; parameter in Joomla components. This is the default filter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Allow a-z, 0-9, underscore, dot, dash. Also remove leading dots from result. &lt;br /&gt;
$result = (string) preg_replace(&#039;/[^A-Z0-9_\.-]/i&#039;, &#039;&#039;, $source);&lt;br /&gt;
$result = ltrim($result, &#039;.&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;BASE64&amp;quot; - base64 can be used to encode a URL as a string of text, which is then stored in a request parameter. For example, if a user accesses a URL which is protected then he/she may be redirected to the URL of the login page, with the original URL being base64 encoded and stored as a (return) parameter within the redirected URL. Once the user has logged in correctly the return parameter is retrieved and he/she is redirected back to the original URL accessed. (Note that you still have to decode the base64 yourself, the filter doesn&#039;t do this for you). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Allow a-z, 0-9, slash, plus, equals.&lt;br /&gt;
$result = (string) preg_replace(&#039;/[^A-Z0-9\/+=]/i&#039;, &#039;&#039;, $source);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;STRING&amp;quot;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Converts the input to a plain text string; strips all tags / attributes.&lt;br /&gt;
$result = (string) $this-&amp;gt;_remove($this-&amp;gt;_decode((string) $source));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;HTML&amp;quot;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Converts the input to a string; strips all HTML tags / attributes.&lt;br /&gt;
$result = (string) $this-&amp;gt;_remove($this-&amp;gt;_decode((string) $source));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;ARRAY&amp;quot;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Attempts to convert the input to an array.&lt;br /&gt;
$result = (array) $source;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;PATH&amp;quot;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Converts the input into a string and validates it as a path. (e.g. path/to/file.png or path/to/dir)&lt;br /&gt;
// Note: Does NOT accept absolute paths, or paths ending in a trailing slash.&lt;br /&gt;
// For a visual representation of the pattern matching used, see http://www.regexper.com/#^[A-Za-z0-9_-]%2B[A-Za-z0-9_\.-]*%28[\\\\\%2F][A-Za-z0-9_-]%2B[A-Za-z0-9_\.-]*%29*%24&lt;br /&gt;
// Will return null if the input was invalid.&lt;br /&gt;
$pattern = &#039;/^[A-Za-z0-9_-]+[A-Za-z0-9_\.-]*([\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/&#039;;&lt;br /&gt;
preg_match($pattern, (string) $source, $matches);&lt;br /&gt;
$result = @ (string) $matches[0];&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;RAW&amp;quot; - be careful using this, to avoid injection attacks on your website!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// The raw input. No sanitisation provided.&lt;br /&gt;
$result = $source;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;USERNAME&amp;quot;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Strips all invalid username characters.&lt;br /&gt;
$result = (string) preg_replace(&#039;/[\x00-\x1F\x7F&amp;lt;&amp;gt;&amp;quot;\&#039;%&amp;amp;]/&#039;, &#039;&#039;, $source)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively instead of adding the filter you can use the JInput type specific methods, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Instead of:&lt;br /&gt;
$input-&amp;gt;get(&#039;name&#039;, &#039;&#039;, &#039;STRING&#039;);&lt;br /&gt;
// you can use:&lt;br /&gt;
$input-&amp;gt;getString(&#039;name&#039;, &#039;&#039;);&lt;br /&gt;
&lt;br /&gt;
// Instead of:&lt;br /&gt;
$input-&amp;gt;get(&#039;memberId&#039;, 0, &#039;INT&#039;);&lt;br /&gt;
// you can use:&lt;br /&gt;
$input-&amp;gt;getInt(&#039;memberId&#039;, 0);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Except that &amp;lt;tt&amp;gt;getArray()&amp;lt;/tt&amp;gt; is different; see [[Retrieving request data using JInput#Getting Multiple Values|Getting Multiple Values]] below.&lt;br /&gt;
&lt;br /&gt;
To retrieve an object, you can use:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$foo = $input-&amp;gt;get(param_name, null, null);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Module Code ==&lt;br /&gt;
Below is the code for a simple Joomla module which you can install and run to demonstrate retrieval of parameter values. If you are unsure about development and installing a Joomla module then following the tutorial at [[S:MyLanguage/J3.x:Creating a simple module/Introduction| Creating a simple module ]] will help.&lt;br /&gt;
&lt;br /&gt;
In a folder mod_input create the following 2 files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;mod_input.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.1&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;Input demo&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.1&amp;lt;/version&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Code demonstrating use of Joomla Input class to obtain HTTP parameters&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_input&amp;quot;&amp;gt;mod_input.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;mod_input.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted Access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
$app = Factory::getApplication();   // equivalent of $app = JFactory::getApplication();&lt;br /&gt;
$input = $app-&amp;gt;input;&lt;br /&gt;
&lt;br /&gt;
if ($input-&amp;gt;exists(&#039;p1&#039;))&lt;br /&gt;
{&lt;br /&gt;
	$v1 = $input-&amp;gt;get(&#039;p1&#039;, 0, &amp;quot;INT&amp;quot;);  // rhs equivalent to $input-&amp;gt;getInt(&#039;p1&#039;, 0);&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;Int value of p1 is $v1&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	$v1 = $input-&amp;gt;get(&#039;p1&#039;, 0, &amp;quot;UINT&amp;quot;); // uint&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;Uint value of p1 is $v1&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
	$v1 = $input-&amp;gt;get(&#039;p1&#039;, 0, &amp;quot;string&amp;quot;); &lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;String Value of p1 is $v1&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;Parameter p1 not specified&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Zip up the mod_input directory to create &amp;lt;tt&amp;gt;mod_input.zip&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Within your Joomla administrator go to Install Extensions and via the Upload Package File tab upload this zip file to install this sample module.&lt;br /&gt;
&lt;br /&gt;
Make this module visible by editing it (click on it within the Modules page) then:&lt;br /&gt;
# making its status Published&lt;br /&gt;
# selecting a position on the page for it to be shown&lt;br /&gt;
# on the menu assignment tab specify the pages it should appear on&lt;br /&gt;
&lt;br /&gt;
Display a web page on which this module appears. Then add the &amp;lt;tt&amp;gt;p1&amp;lt;/tt&amp;gt; parameter to the URL&lt;br /&gt;
* if the URL has no existing parameters then append &amp;lt;tt&amp;gt;?p1=123abc&amp;lt;/tt&amp;gt;&lt;br /&gt;
* if the URL has existing parameters then append &amp;lt;tt&amp;gt;&amp;amp;p1=123abc&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see the results of retrieving the p1 parameter, and passing it through different filters.&lt;br /&gt;
You can experiment by specifying different values for p1, applying different filters, and you can use a utility such as [https://curl.haxx.se/ curl] to send HTTP POST parameters to confirm it works for those as well. &lt;br /&gt;
&lt;br /&gt;
== Getting Multiple Values ==&lt;br /&gt;
&lt;br /&gt;
To retrieve a number of values you can use the &amp;lt;code&amp;gt;getArray()&amp;lt;/code&amp;gt; method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$fooValues = $input-&amp;gt;getArray(array(&#039;p1&#039; =&amp;gt; &#039;&#039;, &#039;p2&#039; =&amp;gt; &#039;&#039;, &#039;p3&#039; =&amp;gt; &#039;&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or, if you want to determine the data to get step by step:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$fooArray = array();&lt;br /&gt;
$fooArray[&#039;p1&#039;] = &#039;&#039;;&lt;br /&gt;
$fooArray[&#039;p2&#039;] = &#039;&#039;;&lt;br /&gt;
$fooArray[&#039;p3&#039;] = &#039;&#039;;&lt;br /&gt;
$fooValues = $input-&amp;gt;getArray($fooArray);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;$fooValues&amp;lt;/code&amp;gt; will be an array that consists of the same keys as used in &amp;lt;code&amp;gt;$fooArray&amp;lt;/code&amp;gt;, but with values attached.&lt;br /&gt;
&lt;br /&gt;
You can also specify different filters for each of the inputs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;gt;&lt;br /&gt;
$fooValues = $input-&amp;gt;getArray(array(&lt;br /&gt;
    &#039;p1&#039; =&amp;gt; &#039;int&#039;,&lt;br /&gt;
    &#039;p2&#039; =&amp;gt; &#039;float&#039;,&lt;br /&gt;
    &#039;p3&#039; =&amp;gt; &#039;word&#039;&lt;br /&gt;
));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also nest arrays to get more complicated hierarchies of values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$fooValues = $input-&amp;gt;getArray(array(&lt;br /&gt;
    &#039;jform&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;title&#039; =&amp;gt; &#039;string&#039;,&lt;br /&gt;
        &#039;quantity&#039; =&amp;gt; &#039;int&#039;,&lt;br /&gt;
        &#039;state&#039; =&amp;gt; &#039;int&#039;&lt;br /&gt;
    )&lt;br /&gt;
));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting Values from a Specific Super Global ==&lt;br /&gt;
&lt;br /&gt;
You can retrieve values relating specifically to the PHP &amp;lt;tt&amp;gt;$_GET&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;$_POST&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;$_SERVER&amp;lt;/tt&amp;gt; global variables: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$val = $input-&amp;gt;get-&amp;gt;get(param_name, default_value, filter);&lt;br /&gt;
$val = $input-&amp;gt;post-&amp;gt;get(param_name, default_value, filter);&lt;br /&gt;
$val = $input-&amp;gt;server-&amp;gt;get(param_name, default_value, filter);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting JSON string from request ==&lt;br /&gt;
&#039;&#039;&#039;NB!&#039;&#039;&#039; Available since Joomla! version 3.0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$json = $input-&amp;gt;json-&amp;gt;get(param_name);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting Values ==&lt;br /&gt;
&lt;br /&gt;
The functions &amp;lt;tt&amp;gt;set()&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;def()&amp;lt;/tt&amp;gt; allow you to set input parameters and their values. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$input-&amp;gt;set(&#039;p2&#039;, &amp;quot;someval&amp;quot;); &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
sets the value of parameter p2 to the string &amp;quot;someval&amp;quot; (creating p2 if it doesn&#039;t already exist).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;  &lt;br /&gt;
$input-&amp;gt;def(&#039;p2&#039;, &amp;quot;someval&amp;quot;); &lt;br /&gt;
&amp;lt;/source&amp;gt;   &lt;br /&gt;
creates a parameter p2 and sets its value to the string &amp;quot;someval&amp;quot;, but only if p2 doesn&#039;t already exist. If p2 already exists then &amp;lt;tt&amp;gt;def(&#039;p2&#039;, &amp;quot;someval&amp;quot;);&amp;lt;/tt&amp;gt; does nothing. &lt;br /&gt;
&lt;br /&gt;
== Retrieving File Data ==&lt;br /&gt;
&lt;br /&gt;
The format that PHP returns file data in for arrays can at times be awkward, especially when dealing with arrays of files. JInputFiles provides a convenient interface for making life a little easier, grouping the data by file.&lt;br /&gt;
&lt;br /&gt;
Suppose you have a form like:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;&amp;lt;?php echo JRoute::_(&#039;index.php?option=com_example&amp;amp;task=file.submit&#039;); ?&amp;gt;&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot; method=&amp;quot;post&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;input type=&amp;quot;file&amp;quot; name=&amp;quot;jform1[test][]&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;input type=&amp;quot;file&amp;quot; name=&amp;quot;jform1[test][]&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;submit&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Normally, PHP would put these in an array called &amp;lt;code&amp;gt;$_FILES&amp;lt;/code&amp;gt; that looked like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Array&lt;br /&gt;
(&lt;br /&gt;
    [jform1] =&amp;gt; Array&lt;br /&gt;
        (&lt;br /&gt;
            [name] =&amp;gt; Array&lt;br /&gt;
                (&lt;br /&gt;
                    [test] =&amp;gt; Array&lt;br /&gt;
                        (&lt;br /&gt;
                            [0] =&amp;gt; youtube_icon.png&lt;br /&gt;
                            [1] =&amp;gt; Younger_Son_2.jpg&lt;br /&gt;
                        )&lt;br /&gt;
&lt;br /&gt;
                )&lt;br /&gt;
&lt;br /&gt;
            [type] =&amp;gt; Array&lt;br /&gt;
                (&lt;br /&gt;
                    [test] =&amp;gt; Array&lt;br /&gt;
                        (&lt;br /&gt;
                            [0] =&amp;gt; image/png&lt;br /&gt;
                            [1] =&amp;gt; image/jpeg&lt;br /&gt;
                        )&lt;br /&gt;
&lt;br /&gt;
                )&lt;br /&gt;
&lt;br /&gt;
            [tmp_name] =&amp;gt; Array&lt;br /&gt;
                (&lt;br /&gt;
                    [test] =&amp;gt; Array&lt;br /&gt;
                        (&lt;br /&gt;
                            [0] =&amp;gt; /tmp/phpXoIpSD&lt;br /&gt;
                            [1] =&amp;gt; /tmp/phpWDE7ye&lt;br /&gt;
                        )&lt;br /&gt;
&lt;br /&gt;
                )&lt;br /&gt;
&lt;br /&gt;
            [error] =&amp;gt; Array&lt;br /&gt;
                (&lt;br /&gt;
                    [test] =&amp;gt; Array&lt;br /&gt;
                        (&lt;br /&gt;
                            [0] =&amp;gt; 0&lt;br /&gt;
                            [1] =&amp;gt; 0&lt;br /&gt;
                        )&lt;br /&gt;
&lt;br /&gt;
                )&lt;br /&gt;
&lt;br /&gt;
            [size] =&amp;gt; Array&lt;br /&gt;
                (&lt;br /&gt;
                    [test] =&amp;gt; Array&lt;br /&gt;
                        (&lt;br /&gt;
                            [0] =&amp;gt; 34409&lt;br /&gt;
                            [1] =&amp;gt; 99529&lt;br /&gt;
                        )&lt;br /&gt;
&lt;br /&gt;
                )&lt;br /&gt;
&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
JInputFiles produces a result that is cleaner and easier to work with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$files = $input-&amp;gt;files-&amp;gt;get(&#039;jform1&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;$files&amp;lt;/code&amp;gt; then becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Array&lt;br /&gt;
(&lt;br /&gt;
    [test] =&amp;gt; Array&lt;br /&gt;
        (&lt;br /&gt;
            [0] =&amp;gt; Array&lt;br /&gt;
                (&lt;br /&gt;
                    [name] =&amp;gt; youtube_icon.png&lt;br /&gt;
                    [type] =&amp;gt; image/png&lt;br /&gt;
                    [tmp_name] =&amp;gt; /tmp/phpXoIpSD&lt;br /&gt;
                    [error] =&amp;gt; 0&lt;br /&gt;
                    [size] =&amp;gt; 34409&lt;br /&gt;
                )&lt;br /&gt;
&lt;br /&gt;
            [1] =&amp;gt; Array&lt;br /&gt;
                (&lt;br /&gt;
                    [name] =&amp;gt; Younger_Son_2.jpg&lt;br /&gt;
                    [type] =&amp;gt; image/jpeg&lt;br /&gt;
                    [tmp_name] =&amp;gt; /tmp/phpWDE7ye&lt;br /&gt;
                    [error] =&amp;gt; 0&lt;br /&gt;
                    [size] =&amp;gt; 99529&lt;br /&gt;
                )&lt;br /&gt;
&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this way, the data from each file element is consolidated into a single array and can be indexed in a more straightforward manner.&lt;br /&gt;
&lt;br /&gt;
== Restrictions and Limitations ==&lt;br /&gt;
To be able to use JInput as described here, you must be using Joomla 2.5.0 or above.&lt;br /&gt;
&lt;br /&gt;
Please note there were known issues with JInput and Magic Quotes (Deprecated in PHP 5.3.0 and removed in PHP 5.4.0). For this reason all core components in Joomla 2.5.x still used JRequest. As of Joomla 3.0+ magic quotes is required to be disabled and thus this is no longer an issue.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Creating_a_custom_form_field_type&amp;diff=1033489</id>
		<title>Creating a custom form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Creating_a_custom_form_field_type&amp;diff=1033489"/>
		<updated>2024-11-27T10:47:02Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to the [https://manual.joomla.org/docs/general-concepts/forms-fields/custom-fields-overview/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{Joomla version|version=3.x|comment=&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
series&amp;lt;/translate&amp;gt;}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{-}}&lt;br /&gt;
{{page|needs review}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
[https://api.joomla.org/cms-3/classes/Joomla.CMS.Form.Form.html JForm], a feature introduced in Joomla! 2.5, lets you easily create HTML forms (&#039;&#039;&amp;lt;form&amp;gt;&#039;&#039;). Forms created using JForm consist of [[S:MyLanguage/Form field|form fields]], implemented as [https://api.joomla.org/cms-3/classes/Joomla.CMS.Form.FormField.html JFormField]. There is a JFormField for each different field type you can find in a form, such as a text field type and a date field type. JForm supports a large selection of standard field types. For a full list, see [[S:MyLanguage/Standard form field types|Standard form field types]].&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
Joomla! makes it possible to extend standard field types or define your own. For example, if your component manages phone book entries, you might want to define a form field type that outputs a select list of cities. There are several advantages to defining a custom form field type:&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* You will be able to mix standard field types with your custom field type in a JForm-based form.&lt;br /&gt;
* You will eventually have a reusable code package that can be used easily throughout your code.&lt;br /&gt;
* Extensions that collaborate with your extension will be able to create form fields without meddling with your database tables and other internals.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Form Field Type Class Requirements == &amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
A form field type is defined in a [[wikipedia:Class (computer programming)|class]] that must be a (not necessarily direct) subclass of JFormField. To work correctly, the class must define at least three methods:&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;public function getLabel()&#039;&#039;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
*: This function will be called to create the label that belongs to your field and must return an HTML string containing it. Since JFormField defines a ready-to-use &#039;&#039;getLabel()&#039;&#039; implementation, custom form field types usually do not define their own &#039;&#039;getLabel()&#039;&#039;. If you leave it out, the inherited method of creating labels will be used. It is recommended to leave out the &#039;&#039;getLabel()&#039;&#039; method for consistency and speed unless you actually want to modify the label&#039;s HTML.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &#039;&#039;public function getInput()&#039;&#039;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
*: This function will be called to create the field itself and must return an HTML string containing it. This is also where most of the processing usually happens. In our phone book City field example, this function will have to retrieve a list of available cities and return an HTML &#039;&#039;&amp;lt;select&amp;gt;&#039;&#039; with the cities inserted as &#039;&#039;&amp;lt;option&amp;gt;&#039;&#039;s.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &#039;&#039;public function getValue()&#039;&#039;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
*: This function will be called to get the field value. The value is obtained from the function LoadFormData in the Model&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
Inside your code, you will have to process the attributes set by the field&#039;s user in the XML form definition. Some of those attributes are accessible via protected member variables of JFormField. For example, the &#039;&#039;name&#039;&#039; attribute is available in your code as &#039;&#039;$this-&amp;gt;name&#039;&#039;. Similarly, &#039;&#039;label&#039;&#039;, &#039;&#039;description&#039;&#039;, &#039;&#039;default&#039;&#039;, &#039;&#039;multiple&#039;&#039; and &#039;&#039;class&#039;&#039; are also available as properties of &#039;&#039;$this&#039;&#039;. Other parameters you might have defined can be accessed through the &#039;&#039;$this-&amp;gt;element&#039;&#039; array: the attribute &#039;&#039;size&#039;&#039; will be in &#039;&#039;$this-&amp;gt;element[&#039;size&#039;]&#039;&#039;.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Which Class to Subclass? == &amp;lt;!--T:65--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
For a form field type to be usable in JForm, it needs to be a subclass of JFormField. However, it does not have to be a direct child of that class. You can also subclass an existing (standard or custom) form field type and thereby inherit useful code.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
If your form field type is similar to an existing type, you &#039;&#039;&#039;should&#039;&#039;&#039; subclass that type. Especially if your form field type is a &#039;&#039;list&#039;&#039;, please subclass [https://api.joomla.org/cms-3/classes/JFormFieldList.html JFormFieldList]. You only have to override &#039;&#039;getOptions()&#039;&#039; method to return the options to be shown. The &#039;&#039;getInput()&#039;&#039; method will convert those options to HTML.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
To subclass an existing type, for example JFormFieldList, load it by adding the following after &#039;&#039;jimport(&#039;joomla.form.formfield&#039;);&#039;&#039;:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
jimport(&#039;joomla.form.helper&#039;);&lt;br /&gt;
JFormHelper::loadFieldClass(&#039;list&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
If your form field type is unlike any existing type, subclass &#039;&#039;JFormField&#039;&#039; directly.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Location of Files == &amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
* The standard form field types are located in &#039;&#039;libraries/joomla/form/fields/&#039;&#039;. You should not store custom fields there, nor should you have to use this path in your own code. The standard types are usually good examples.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
* The custom field types that belong to your component are usually located in &#039;&#039;administrator/components/&amp;lt;name of your component&amp;gt;/models/fields&#039;&#039;. You can specify this or another path in your code:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;JForm::addFieldPath(JPATH_COMPONENT . &#039;/models/fields&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
* The XML files that define forms are usually located in &#039;&#039;administrator/components/&amp;lt;name of your component&amp;gt;/models/forms&#039;&#039;. Use something like the following snippet to specify a path to your forms:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;JForm::addFormPath(JPATH_COMPONENT . &#039;/models/forms&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Naming Conventions and Skeleton == &amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
In this section, &amp;lt;ComponentName&amp;gt; represents the camel-cased name of your component and &amp;lt;FieldName&amp;gt; represents the camel-cased name of your form field type. The field&#039;s class should be placed in &#039;&#039;administrator/components/&amp;lt;name of your component&amp;gt;/models/fields/&amp;lt;name of your field&amp;gt;.php&#039;&#039;, and look like this:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
// Check to ensure this file is included in Joomla!&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
jimport(&#039;joomla.form.formfield&#039;);&lt;br /&gt;
&lt;br /&gt;
// The class name must always be the same as the filename (in camel case)&lt;br /&gt;
class JFormField&amp;lt;FieldName&amp;gt; extends JFormField {&lt;br /&gt;
&lt;br /&gt;
	//The field class must know its own type through the variable $type.&lt;br /&gt;
	protected $type = &#039;&amp;lt;FieldName&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
	public function getLabel() {&lt;br /&gt;
		// code that returns HTML that will be shown as the label&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public function getInput() {&lt;br /&gt;
		// code that returns HTML that will be shown as the form field&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== Grouping Custom Field Types === &amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Warning: this information is partially incorrect and needs to be improved.&#039;&#039;&#039;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
Custom field types can be grouped by using an underscore in the field name. A field class with a name for example like &amp;quot;JFormFieldMy_randomField&amp;quot; must be stored in &#039;&#039;administrator/components/&amp;lt;name of your component&amp;gt;/models/fields/my/randomField.php&#039;&#039;. We can prefix our form field names with some group name, then we put an underscore and then a name of a field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== An Example Custom Field Type == &amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
Suppose you&#039;re working on your component named &#039;&#039;com_phonebook&#039;&#039; and you want to define a field that contains cities. Create the file &#039;&#039;administrator/components/com_phonebook/models/fields/city.php&#039;&#039; and write something similar to the following:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
// Check to ensure this file is included in Joomla!&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
jimport(&#039;joomla.form.formfield&#039;);&lt;br /&gt;
&lt;br /&gt;
class JFormFieldCity extends JFormField {&lt;br /&gt;
&lt;br /&gt;
	protected $type = &#039;City&#039;;&lt;br /&gt;
&lt;br /&gt;
	// getLabel() left out&lt;br /&gt;
&lt;br /&gt;
	public function getInput() {&lt;br /&gt;
		return &#039;&amp;lt;select id=&amp;quot;&#039;.$this-&amp;gt;id.&#039;&amp;quot; name=&amp;quot;&#039;.$this-&amp;gt;name.&#039;&amp;quot;&amp;gt;&#039;.&lt;br /&gt;
		       &#039;&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;New York&amp;lt;/option&amp;gt;&#039;.&lt;br /&gt;
		       &#039;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;Chicago&amp;lt;/option&amp;gt;&#039;.&lt;br /&gt;
		       &#039;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;San Francisco&amp;lt;/option&amp;gt;&#039;.&lt;br /&gt;
		       &#039;&amp;lt;/select&amp;gt;&#039;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
A more advanced approach is extending the &#039;&#039;JFormFieldList&#039;&#039; class. Suppose you want to create a drop-down of cities dynamically from database based on a dynamic condition. You can do this in the following way:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
// Check to ensure this file is included in Joomla!&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
JFormHelper::loadFieldClass(&#039;list&#039;);&lt;br /&gt;
&lt;br /&gt;
class JFormFieldCity extends JFormFieldList {&lt;br /&gt;
&lt;br /&gt;
	protected $type = &#039;City&#039;;&lt;br /&gt;
&lt;br /&gt;
	public function getOptions() {&lt;br /&gt;
                $app = JFactory::getApplication();&lt;br /&gt;
                $country = $app-&amp;gt;input-&amp;gt;get(&#039;country&#039;); //country is the dynamic value which is being used in the view&lt;br /&gt;
                $db = JFactory::getDbo();&lt;br /&gt;
                $query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
                $query-&amp;gt;select(&#039;a.cityname&#039;)-&amp;gt;from(&#039;`#__tablename` AS a&#039;)-&amp;gt;where(&#039;a.country = &amp;quot;&#039;.$country.&#039;&amp;quot; &#039;);&lt;br /&gt;
		$rows = $db-&amp;gt;setQuery($query)-&amp;gt;loadObjectlist();&lt;br /&gt;
                foreach($rows as $row){&lt;br /&gt;
                    $cities[] = $row-&amp;gt;cityname;&lt;br /&gt;
                }&lt;br /&gt;
                // Merge any additional options in the XML definition.&lt;br /&gt;
		$options = array_merge(parent::getOptions(), $cities);&lt;br /&gt;
                return $options;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
The above example shows a simple query which will show a list of cities from a table where city name belongs to its country respectively. You can create a drop-down based on more complex queries.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Setting the Values of a List Option and Using JSON or an API Instead of a Database Call == &amp;lt;!--T:66--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:67--&amp;gt;&lt;br /&gt;
If you want to use an API call instead of a database call to build a custom list item, use the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:68--&amp;gt;&lt;br /&gt;
This field was created in a module. To get it to work it needs to be saved to&lt;br /&gt;
&#039;&#039;mod_modulename/models/fields/stackexchangesites.php&#039;&#039;.&lt;br /&gt;
The naming convention is important as it is used within our function name.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// Check to ensure this file is included in Joomla!&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
// call the list field type&lt;br /&gt;
JFormHelper::loadFieldClass(&#039;list&#039;);&lt;br /&gt;
&lt;br /&gt;
// The class name must always be the same as the filename (in camel case)&lt;br /&gt;
// extend the list field type&lt;br /&gt;
class JFormFieldStackexchangesites extends JFormFieldList&lt;br /&gt;
{&lt;br /&gt;
    //The field class must know its own type through the variable $type.&lt;br /&gt;
    protected $type = &#039;Stackexchangesites&#039;;&lt;br /&gt;
&lt;br /&gt;
    // get the options for the list field&lt;br /&gt;
    public function getOptions()&lt;br /&gt;
    {&lt;br /&gt;
       // insert your JSON here or else call an API&lt;br /&gt;
        $json = {&amp;quot;api_site_parameter&amp;quot;:&amp;quot;meta.stackoverflow&amp;quot;,&amp;quot;site_url&amp;quot;:&amp;quot;https://meta.stackoverflow.com&amp;quot;~}&lt;br /&gt;
        // decode the JSON&lt;br /&gt;
        $sites = json_decode($json, true);&lt;br /&gt;
&lt;br /&gt;
        // use a for each to iterate over the JSON&lt;br /&gt;
        foreach($sites[&#039;items&#039;] as $site)&lt;br /&gt;
        {&lt;br /&gt;
           // choose the element of the JSON we want, and set it as a variable so we can use it in our array.&lt;br /&gt;
            $site = $site[&#039;api_site_parameter&#039;];&lt;br /&gt;
            $site_url = $site[&#039;site_url&#039;];&lt;br /&gt;
            // set an array and start adding values to it.  Set another array within our array to set our value / text items.&lt;br /&gt;
            $stackExchangesSitesOptions[] = array(&amp;quot;value&amp;quot; =&amp;gt; $site, &amp;quot;text&amp;quot; =&amp;gt; $site_url);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        // Merge any additional options in the XML definition.&lt;br /&gt;
        $options = array_merge(parent::getOptions(), $stackExchangesSitesOptions);&lt;br /&gt;
        return $options;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:69--&amp;gt;&lt;br /&gt;
On the Frontend simply calling the parameter gets us the value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$stackexchangesites = $params-&amp;gt;get(&#039;stackexchangesites&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== Pitfalls === &amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
Loading a custom field can result in a Fatal Error if a core field exists with the same filename and the custom field extends the core field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
Consider a file &#039;&#039;testfields/radio.php&#039;&#039; containing&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class TestFormFieldRadio extends JFormFieldRadio {}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
Calling &#039;&#039;JFormHelper::loadFieldClass(&#039;radio&#039;)&#039;&#039; will yield a Fatal error: Class &#039;JFormFieldRadio&#039; not found.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
There are two reasons for this.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
# JLoader cannot autoload &#039;&#039;JFormFieldRadio&#039;&#039; because the class name (&#039;&#039;JFormField*&#039;&#039;) does not match the path name (&#039;&#039;joomla/form/fields/*&#039;&#039; - notice the plural on fields).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
# JFormHelper cannot load &#039;&#039;JFormFieldRadio&#039;&#039; because custom paths are scanned first and the requested field type(&#039;radio&#039;) gets resolved before the core classes are reached.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Solution&#039;&#039;&#039;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:63--&amp;gt;&lt;br /&gt;
Require the core field file directly:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
require_once JPATH_LIBRARIES . &#039;/joomla/form/fields/radio.php&#039;;&lt;br /&gt;
&lt;br /&gt;
class TestFormFieldRadio extends JFormFieldRadio {}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:64--&amp;gt;&lt;br /&gt;
and use &#039;&#039;JFormHelper::loadFieldClass&#039;&#039; properly with &#039;test.radio&#039; instead of &#039;radio&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== Using the Custom Field Type === &amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== Linked with a Form ==== &amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
To use the field type City, we need to update the XML file that contains the form fields. Open your XML file located in &#039;&#039;administrator/components/com_phonebook/models/forms&#039;&#039; and add the field in the usual way:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;title&amp;quot; type=&amp;quot;City&amp;quot; label=&amp;quot;JGLOBAL_TITLE&amp;quot;&lt;br /&gt;
	description=&amp;quot;JFIELD_TITLE_DESC&amp;quot;&lt;br /&gt;
	required=&amp;quot;true&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
The attribute name is cAsE-sEnSiTiVe.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
In addition, you may need to add the field path to the parent &amp;lt;fieldset&amp;gt;:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;fieldset addfieldpath=&amp;quot;/administrator/components/&amp;lt;component name&amp;gt;/models/fields&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== Not Linked with a Form ==== &amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
For example, when you need the field as a dropdown in a component as admin/site filter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
//Get custom field&lt;br /&gt;
JFormHelper::addFieldPath(JPATH_COMPONENT . &#039;/models/fields&#039;);&lt;br /&gt;
$cities = JFormHelper::loadFieldType(&#039;City&#039;, false);&lt;br /&gt;
$cityOptions=$cities-&amp;gt;getOptions(); // works only if you set your field getOptions on public!!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Overriding &#039;&#039;getLabel()&#039;&#039; == &amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
As mentioned in the section [[#Form field type class requirements|Form field type class requirements]], custom form field types usually do not define their own &#039;&#039;getLabel()&#039;&#039;. If you do want to create a custom label, you can still make use of the &#039;&#039;getLabel()&#039;&#039; that every field type class inherits from JFormField by defining it as follows:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;public function getLabel() {&lt;br /&gt;
     return &#039;&amp;lt;span style=&amp;quot;text-decoration: underline;&amp;quot;&amp;gt;&#039; . parent::getLabel() . &#039;&amp;lt;/span&amp;gt;&#039;;&lt;br /&gt;
} &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
This code will underline your form labels. (Please note that if your goal is to underline form labels, using [[CSS]] is the preferred way.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
If you want to do something completely different, you can of course also override it completely:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;public function getLabel() {&lt;br /&gt;
	// Initialize variables.&lt;br /&gt;
	$label = &#039;&#039;;&lt;br /&gt;
	$replace = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// Get the label text from the XML element, defaulting to the element name.&lt;br /&gt;
	$text = $this-&amp;gt;element[&#039;label&#039;] ? (string) $this-&amp;gt;element[&#039;label&#039;] : (string) $this-&amp;gt;element[&#039;name&#039;];&lt;br /&gt;
&lt;br /&gt;
	// Build the class for the label.&lt;br /&gt;
	$class = !empty($this-&amp;gt;description) ? &#039;hasTip&#039; : &#039;&#039;;&lt;br /&gt;
	$class = $this-&amp;gt;required == true ? $class.&#039; required&#039; : $class;&lt;br /&gt;
&lt;br /&gt;
	// Add replace checkbox&lt;br /&gt;
	$replace = &#039;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;update[&#039;.$this-&amp;gt;name.&#039;]&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// Add the opening label tag and main attributes attributes.&lt;br /&gt;
	$label .= &#039;&amp;lt;label id=&amp;quot;&#039;.$this-&amp;gt;id.&#039;-lbl&amp;quot; for=&amp;quot;&#039;.$this-&amp;gt;id.&#039;&amp;quot; class=&amp;quot;&#039;.$class.&#039;&amp;quot;&#039;;&lt;br /&gt;
&lt;br /&gt;
	// If a description is specified, use it to build a tooltip.&lt;br /&gt;
	if (!empty($this-&amp;gt;description)) {&lt;br /&gt;
		$label .= &#039; title=&amp;quot;&#039;.htmlspecialchars(trim(JText::_($text), &#039;:&#039;).&#039;::&#039; .&lt;br /&gt;
				JText::_($this-&amp;gt;description), ENT_COMPAT, &#039;UTF-8&#039;).&#039;&amp;quot;&#039;;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	// Add the label text and closing tag.&lt;br /&gt;
	$label .= &#039;&amp;gt;&#039;.$replace.JText::_($text).&#039;&amp;lt;/label&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
	return $label;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
This example will add a checkbox inside the label.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Component Code ==&lt;br /&gt;
Below is the code for a small component which you can install and run and can adapt to experiment further with custom fields. The component includes two custom fields&lt;br /&gt;
# A &amp;quot;City&amp;quot; field as described above (except that the options are hard-coded rather than being selected from a database). We&#039;ll also allow multiple Cities to be selected and pre-select two of them as default.&lt;br /&gt;
# A custom &amp;quot;time&amp;quot; field which maps to the HTML &amp;quot;time&amp;quot; input type and includes underlining the label and support for setting a minimum and maximum time.&lt;br /&gt;
&lt;br /&gt;
Create the following five files in a folder called com_custom_fields. Then zip up this folder to create com_custom_fields.zip. Install this component on your Joomla instance. Once installed, navigate on your browser to your Joomla site and add to the URL the parameter &#039;&#039;&amp;amp;option=com_custom_fields&#039;&#039;. This should display the form with the two custom fields. You can submit the form and see the HTTP POST parameters using the browser development tools but the component doesn&#039;t contain any code which handles those parameters.&lt;br /&gt;
&lt;br /&gt;
(As described in [[Basic_form_guide#MVC_and_other_considerations|Basic form guide]], the approach below isn&#039;t the recommended way to design Joomla components but it&#039;s written in this minimalist fashion to focus on the custom fields aspects).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_custom_fields.xml&#039;&#039; The manifest file for the component.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;component&amp;quot; version=&amp;quot;3.1.0&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;name&amp;gt;com_custom_fields&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;Custom Fields demo component&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;administration&amp;gt;&lt;br /&gt;
	&amp;lt;/administration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files folder=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;custom_fields.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;form_definition.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;City.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;Time.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;custom_fields.php&#039;&#039; The main code file which is run when an HTTP GET or POST is directed towards this component.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted Access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Form\Form;&lt;br /&gt;
&lt;br /&gt;
$form = Form::getInstance(&amp;quot;sample&amp;quot;, __DIR__ . &amp;quot;/form_definition.xml&amp;quot;, array(&amp;quot;control&amp;quot; =&amp;gt; &amp;quot;jform&amp;quot;));&lt;br /&gt;
Form::addFieldPath(__DIR__);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;&amp;lt;?php echo JRoute::_(&#039;index.php?option=com_custom_fields&#039;); ?&amp;gt;&amp;quot;&lt;br /&gt;
    method=&amp;quot;post&amp;quot; name=&amp;quot;adminForm&amp;quot; id=&amp;quot;adminForm&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;?php echo $form-&amp;gt;renderField(&#039;mytime&#039;);  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;?php echo $form-&amp;gt;renderField(&#039;mycity&#039;);  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;Submit&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;form_definition.xml&#039;&#039; File containing the XML for the form definition, basically the two custom fields.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form name=&amp;quot;myForm&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;field&lt;br /&gt;
		name=&amp;quot;mytime&amp;quot;&lt;br /&gt;
		type=&amp;quot;time&amp;quot;&lt;br /&gt;
		label=&amp;quot;Time:&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
		min=&amp;quot;09:00&amp;quot;&lt;br /&gt;
		max=&amp;quot;17:30&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;field name=&amp;quot;mycity&amp;quot;&lt;br /&gt;
		type=&amp;quot;City&amp;quot;&lt;br /&gt;
		label=&amp;quot;City:&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot;&lt;br /&gt;
		multiple=&amp;quot;true&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;City.php&#039;&#039; PHP code for the City custom field.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
use Joomla\CMS\Form\FormHelper;&lt;br /&gt;
&lt;br /&gt;
FormHelper::loadFieldClass(&#039;list&#039;);&lt;br /&gt;
&lt;br /&gt;
class JFormFieldCity extends JFormFieldList {&lt;br /&gt;
&lt;br /&gt;
	protected $type = &#039;City&#039;;&lt;br /&gt;
&lt;br /&gt;
	public function getOptions() {&lt;br /&gt;
		$cities = array(&lt;br /&gt;
					array(&#039;value&#039; =&amp;gt; 1, &#039;text&#039; =&amp;gt; &#039;New York&#039;),&lt;br /&gt;
					array(&#039;value&#039; =&amp;gt; 2, &#039;text&#039; =&amp;gt; &#039;Chicago&#039;),&lt;br /&gt;
					array(&#039;value&#039; =&amp;gt; 3, &#039;text&#039; =&amp;gt; &#039;San Francisco&#039;),&lt;br /&gt;
					);&lt;br /&gt;
		// Merge any additional options in the XML definition.&lt;br /&gt;
		$options = array_merge(parent::getOptions(), $cities);&lt;br /&gt;
&lt;br /&gt;
		// pre-select values 2 and 3 by setting the protected $value property&lt;br /&gt;
		$this-&amp;gt;value = array(2, 3);&lt;br /&gt;
&lt;br /&gt;
		return $options;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Time.php&#039;&#039; PHP code for the time custom field.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;JPATH_PLATFORM&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
use Joomla\CMS\Form\FormField;&lt;br /&gt;
&lt;br /&gt;
class JFormFieldTime extends FormField&lt;br /&gt;
{&lt;br /&gt;
	protected $type = &#039;time&#039;;&lt;br /&gt;
&lt;br /&gt;
	protected function getInput()&lt;br /&gt;
	{&lt;br /&gt;
		// get relevant attributes which were defined in the XML form definition&lt;br /&gt;
		$attr = !empty($this-&amp;gt;class) ? &#039; class=&amp;quot;&#039; . $this-&amp;gt;class . &#039;&amp;quot;&#039; : &#039;&#039;;&lt;br /&gt;
		$attr .= !empty($this-&amp;gt;element[&#039;min&#039;]) ? &#039; min=&amp;quot;&#039; . $this-&amp;gt;element[&#039;min&#039;] . &#039;&amp;quot;&#039; : &#039;&#039;;&lt;br /&gt;
		$attr .= !empty($this-&amp;gt;element[&#039;max&#039;]) ? &#039; max=&amp;quot;&#039; . $this-&amp;gt;element[&#039;max&#039;] . &#039;&amp;quot;&#039; : &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
		// set up html, including the value and other attributes&lt;br /&gt;
		$html = &#039;&amp;lt;input type=&amp;quot;time&amp;quot; name=&amp;quot;&#039; . $this-&amp;gt;name . &#039;&amp;quot; value=&amp;quot;&#039; . $this-&amp;gt;value . &#039;&amp;quot;&#039; . $attr . &#039;/&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
		return $html;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public function getLabel() {&lt;br /&gt;
		return &#039;&amp;lt;span style=&amp;quot;text-decoration: underline;&amp;quot;&amp;gt;&#039; . parent::getLabel() . &#039;&amp;lt;/span&amp;gt;&#039;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Extension development]]&lt;br /&gt;
[[Category:Form fields]]&lt;br /&gt;
[[Category:Joomla! 2.5]]&lt;br /&gt;
[[Category:Joomla! 3.x]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Advanced_form_guide&amp;diff=1033488</id>
		<title>Advanced form guide</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Advanced_form_guide&amp;diff=1033488"/>
		<updated>2024-11-27T10:43:22Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to the [https://manual.joomla.org/docs/general-concepts/forms/manipulating-forms/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This is one of a series of [[API Guides]], which aim to help you understand how to use the Joomla APIs through providing detailed explanations and sample code which you can easily install and run. &lt;br /&gt;
&lt;br /&gt;
This guide describes more advanced features of the Joomla Form API than is covered in [[Basic form guide]], and comprises the following aspects:&lt;br /&gt;
* setting the file Path to enable Joomla to find your definitions of your form, your form fields and your form field validation, in the case where you don&#039;t follow the Joomla standards.&lt;br /&gt;
* defining groupings of fields – Joomla provides two types, namely fieldsets and field groups.&lt;br /&gt;
* dynamically changing your form (after it&#039;s been loaded from an XML file)&lt;br /&gt;
* reflection-like methods which allow you to extract information from your form structure and data.&lt;br /&gt;
&lt;br /&gt;
The guide concludes with a sample component with examples of the above aspects. &lt;br /&gt;
&lt;br /&gt;
== File Paths ==&lt;br /&gt;
By default Joomla will look in the …/models/forms folder of your component to find the XML definition of your form, within the site files if your form is being displayed on the front end, or within the administrator files if your form is being displayed on the back end. The static function &amp;lt;tt&amp;gt;addFormPath()&amp;lt;/tt&amp;gt; allows you to add a different directory to the list of directories which Joomla will search. &lt;br /&gt;
&lt;br /&gt;
Similarly &amp;lt;tt&amp;gt;addFieldPath()&amp;lt;/tt&amp;gt; allows you to define a different directory for any custom form field definitions (the default being …/models/fields) and &amp;lt;tt&amp;gt;addRulePath()&amp;lt;/tt&amp;gt; allows you to define a different directory for any custom validation rules (the default being …/models/rules). &lt;br /&gt;
&lt;br /&gt;
There are examples of all three in the sample component code at the end of this guide.&lt;br /&gt;
&lt;br /&gt;
== Fieldsets ==&lt;br /&gt;
Fieldsets are associated with the &amp;lt;tt&amp;gt;&amp;lt;fieldset name=&amp;quot;myfieldset&amp;quot;&amp;gt;&amp;lt;/tt&amp;gt; element in the XML definition of the form. The advantage of using fieldsets is that in your layout file you can use&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;$form-&amp;gt;renderFieldset(&amp;quot;myfieldset&amp;quot;);&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to render all the fields which have &amp;lt;tt&amp;gt;&amp;lt;field&amp;gt;&amp;lt;/tt&amp;gt; elements inside the &amp;lt;tt&amp;gt;&amp;lt;fieldset&amp;gt;&amp;lt;/tt&amp;gt; opening and closing tags. This is instead of having to call &amp;lt;tt&amp;gt;renderField()&amp;lt;/tt&amp;gt; for each field within the fieldset.&lt;br /&gt;
&lt;br /&gt;
A fieldset can be viewed as a set of fields which should be displayed together in a form, and are thus similar in concept to the HTML &amp;lt;fieldset&amp;gt; element. However, note that &amp;lt;tt&amp;gt; renderFieldset()&amp;lt;/tt&amp;gt; does not output the HTML &amp;lt;fieldset&amp;gt; or related tags. &lt;br /&gt;
&lt;br /&gt;
== Field Groups ==&lt;br /&gt;
Field groups are associated with the &amp;lt;tt&amp;gt;&amp;lt;fields name=&amp;quot;mygroup&amp;quot;&amp;gt;&amp;lt;/tt&amp;gt; element in the XML definition of the form. This affects the HTML name attribute which is assigned to HTML input elements of fields which are defined within the &amp;lt;tt&amp;gt;&amp;lt;fields&amp;gt;&amp;lt;/tt&amp;gt; opening and closing tags in the XML form definition, and hence the name of the parameter as sent to the server in the HTTP POST request. &lt;br /&gt;
&lt;br /&gt;
If you specify the option &amp;lt;tt&amp;gt;&amp;quot;control&amp;quot; =&amp;gt; &amp;quot;myform&amp;quot;&amp;lt;/tt&amp;gt; when you set up your Form instance then input field values will be sent to the server in the HTTP POST request keyed like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;myform[field1]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;myform[field2]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;myform[field3]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you enclose these fields in the XML form definition within a &amp;lt;tt&amp;gt;&amp;lt;fields name=&amp;quot;mygroup&amp;quot;&amp;gt;&amp;lt;/tt&amp;gt; element then the POST parameters will be sent with names like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;myform[mygroup][field1]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;myform[mygroup][field2]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;myform[mygroup][field3]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your component has a database table and you store a number of parameters in a json string in one of the columns of the table, then you can group the HTML input elements of those parameters inside a &amp;lt;tt&amp;gt;&amp;lt;fields&amp;gt;&amp;lt;/tt&amp;gt; element. If you name the fields tag to match your column name then you can use the Joomla Table functionality to easily convert the PHP associative array arising from the POST parameters into the json string for storing in the database. &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;$group&amp;lt;/tt&amp;gt; parameter which appears in several Form API methods refers to the name attribute of the &amp;lt;tt&amp;gt;&amp;lt;fields&amp;gt;&amp;lt;/tt&amp;gt; tag in the form definition XML. &lt;br /&gt;
&lt;br /&gt;
Examples of this approach can be seen in the Joomla MVC tutorial [[J3.x:Developing an MVC Component/Adding an Image|Adding an Image]] step and many of the Joomla core components.&lt;br /&gt;
&lt;br /&gt;
Note that fieldsets and field groups are independent. In your form XML definition you can have &amp;lt;tt&amp;gt;&amp;lt;fields&amp;gt;&amp;lt;/tt&amp;gt; elements within &amp;lt;tt&amp;gt;&amp;lt;fieldset&amp;gt;&amp;lt;/tt&amp;gt; elements, and also &amp;lt;tt&amp;gt;&amp;lt;fieldset&amp;gt;&amp;lt;/tt&amp;gt; elements within &amp;lt;tt&amp;gt;&amp;lt;fields&amp;gt;&amp;lt;/tt&amp;gt; elements.&lt;br /&gt;
&lt;br /&gt;
== Dynamically Changing Forms ==&lt;br /&gt;
If you have defined your form statically in an XML file, then once it&#039;s been loaded you can modify it dyamically in your PHP code using the Form APIs &lt;br /&gt;
* adding further fields to your form by loading another form XML definition &lt;br /&gt;
* modifying an existing field or fields, &lt;br /&gt;
* removing a field or group of fields.&lt;br /&gt;
&lt;br /&gt;
=== Adding Fields via form definition ===&lt;br /&gt;
To include additional definitions from a file into your form do&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;$form-&amp;gt;loadFile($filename);&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
passing the &amp;lt;tt&amp;gt;$filename&amp;lt;/tt&amp;gt; of an XML file structured in the same way as your main form definition file. &lt;br /&gt;
&lt;br /&gt;
Alternatively you can create a SimpleXMLElement ($xml say) in your code which contains the same XML and then call &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;$form-&amp;gt;load($xml);&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(The Joomla code for &amp;lt;tt&amp;gt;loadFile()&amp;lt;/tt&amp;gt; just reads the data from the file into a SimpleXMLElement variable and then calls &amp;lt;tt&amp;gt;load()&amp;lt;/tt&amp;gt;). &lt;br /&gt;
&lt;br /&gt;
With both these functions you can pass additional parameters:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;$replace&amp;lt;/tt&amp;gt; (in the &amp;lt;tt&amp;gt;load()&amp;lt;/tt&amp;gt; method) / &amp;lt;tt&amp;gt;$reset&amp;lt;/tt&amp;gt; (in the &amp;lt;tt&amp;gt;loadFile()&amp;lt;/tt&amp;gt; method) – both of these have the same effect, and relate to the case where a field in the XML being loaded has a name which is the same as one in the form already. If set to &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; then the new field replaces the old one.  If set to &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; then the new field is ignored. &lt;br /&gt;
* &amp;lt;tt&amp;gt;$xpath&amp;lt;/tt&amp;gt; – if you want only part of the XML structure being loaded to be considered then you can specify an &amp;lt;tt&amp;gt;xpath&amp;lt;/tt&amp;gt; to select the part or parts of the XML you want to include. &lt;br /&gt;
&lt;br /&gt;
In addition to the example in the sample code below, you can find examples of loading additional XML files in the core Joomla administrator &amp;lt;tt&amp;gt;com_menu&amp;lt;/tt&amp;gt; code, related to when an admin is setting up site menu options. The basic options for a site menuitem are specified in the &amp;lt;tt&amp;gt;item.xml&amp;lt;/tt&amp;gt; file in administrator/com_menus/models/forms, but in the &amp;lt;tt&amp;gt;com_menu&amp;lt;/tt&amp;gt; model &amp;lt;tt&amp;gt;item.php&amp;lt;/tt&amp;gt; code this is supplemented with options defined in the XML file which is in the layout directory related to the site page which is going to be displayed. &lt;br /&gt;
&lt;br /&gt;
An example of building and loading an XML structure is in the Joomla MVC development tutorial [[J3.x:Developing an MVC Component/Adding Associations|Adding Associations]] step, where the Associations fields are added dynamically this way, because the associations to be added depend upon what the language of the record is. &lt;br /&gt;
&lt;br /&gt;
=== Dynamically Setting Fields ===&lt;br /&gt;
You can use &amp;lt;tt&amp;gt;setField()&amp;lt;/tt&amp;gt; to add or replace a single field in the Form instance, and &amp;lt;tt&amp;gt;setFields()&amp;lt;/tt&amp;gt; to add or replace several fields. To use these you create the XML relating to a field, then pass this to &amp;lt;tt&amp;gt;setField()&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$xml = new SimpleXMLElement(&#039;&amp;lt;field name=&amp;quot;newfield&amp;quot; … /&amp;gt;&#039;);&lt;br /&gt;
setField($xml);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Similarly you can define an array of such XML elements and pass these to &amp;lt;tt&amp;gt;setFields()&amp;lt;/tt&amp;gt;, which is the equivalent of calling &amp;lt;tt&amp;gt;setField()&amp;lt;/tt&amp;gt; on each of the individual elements. &lt;br /&gt;
&lt;br /&gt;
Specify the &amp;lt;tt&amp;gt;$group&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;$fieldset&amp;lt;/tt&amp;gt; parameters to include the new field within a specific field group and fieldset. &lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;tt&amp;gt;$replace&amp;lt;/tt&amp;gt; parameter is set to &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; then if an existing field with the same field group and name is found, it will be replaced. &lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;tt&amp;gt;$replace&amp;lt;/tt&amp;gt; parameter is set to &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; and an existing field with the same field group and name is found, then the new field will be ignored.&lt;br /&gt;
&lt;br /&gt;
=== Setting Field Attributes and Values ===&lt;br /&gt;
&amp;lt;tt&amp;gt;setFieldAttribute()&amp;lt;/tt&amp;gt; allows you to set / amend an attribute associated with a field. Note that the attribute refers to the Joomla field attribute, rather than the HTML attribute of the input element. For example, to set the HTML &amp;lt;tt&amp;gt;placeholder&amp;lt;/tt&amp;gt; attribute you have to set the Joomla &amp;lt;tt&amp;gt;hint&amp;lt;/tt&amp;gt; field attribute, and this works only if the [[Standard form field types|Form Field type]] supports that attribute. &lt;br /&gt;
&lt;br /&gt;
The HTML &amp;lt;tt&amp;gt;value&amp;lt;/tt&amp;gt; attribute is treated somewhat differently from other HTML attributes. As outlined in the [[Basic form guide]], in the Joomla Form instance the XML form structure (defined by the form definition XML file) is held separately from the form pre-fill data (passed in the &amp;lt;tt&amp;gt;bind()&amp;lt;/tt&amp;gt; method). What is output in the value attribute of the HTML input element is primarily the &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; Joomla form field attribute (if supported for that field type), but this is overridden by any value specified for that field in the &amp;lt;tt&amp;gt;bind()&amp;lt;/tt&amp;gt; call. &lt;br /&gt;
&lt;br /&gt;
You can thus set the &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; attribute using &amp;lt;tt&amp;gt;setFieldAttribute()&amp;lt;/tt&amp;gt;, but to set the field value directly within the pre-fill data use &amp;lt;tt&amp;gt;setValue()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Removing Fields ===&lt;br /&gt;
You can remove fields from the Form definition by calling &amp;lt;tt&amp;gt;removeField()&amp;lt;/tt&amp;gt; to remove a specific field or &amp;lt;tt&amp;gt;removeGroup()&amp;lt;/tt&amp;gt; to remove all the fields within a specified field group.&lt;br /&gt;
&lt;br /&gt;
== Reflection Methods ==&lt;br /&gt;
There are a number of methods which allow you to access various aspects of the Form instance data. Mostly these are fairly straightforward to understand, and only cases where it may not be totally clear are explained below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;getData()&amp;lt;/tt&amp;gt; returns as a Joomla Registry object the pre-fill data which has been set using the Form &amp;lt;tt&amp;gt;bind()&amp;lt;/tt&amp;gt; call. &lt;br /&gt;
&lt;br /&gt;
The methods &amp;lt;tt&amp;gt;getField()&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;getFieldset()&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;getGroup()&amp;lt;/tt&amp;gt; all return fields as Joomla FormField objects, rather than how they&#039;re held internally within the Form instance.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;getFieldsets()&amp;lt;/tt&amp;gt; returns an array of Fieldset objects with properties which reflect the &amp;lt;tt&amp;gt;&amp;lt;fieldset&amp;gt;&amp;lt;/tt&amp;gt; tag in the form definition file. So if you have&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;fieldset name=&amp;quot;myfieldset&amp;quot; label=&amp;quot;myfieldsetLabel&amp;quot; description=&amp;quot;myfieldsetDescription&amp;quot;&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then you can do&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$fieldsets = $form-&amp;gt;getFieldsets();&lt;br /&gt;
echo $fieldsets[&#039;myfieldset&#039;]-&amp;gt;label;   // outputs &amp;quot;myfieldsetLabel&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;getFormControl()&amp;lt;/tt&amp;gt; returns the string from your &amp;lt;tt&amp;gt;$options&amp;lt;/tt&amp;gt; parameter passed when you created the Form instance. If you used the Joomla standard of &amp;lt;tt&amp;gt;&amp;quot;control&amp;quot; =&amp;gt; &amp;quot;jform&amp;quot;&amp;lt;/tt&amp;gt; within this &amp;lt;tt&amp;gt;$options&amp;lt;/tt&amp;gt; array then &amp;lt;tt&amp;gt;getFormControl()&amp;lt;/tt&amp;gt; will return the string &amp;quot;jform&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;getInput()&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;getLabel()&amp;lt;/tt&amp;gt; return the HTML for the &amp;lt;tt&amp;gt;&amp;lt;input&amp;gt;&amp;lt;/tt&amp;gt; tag and &amp;lt;tt&amp;gt;&amp;lt;label&amp;gt;&amp;lt;/tt&amp;gt; respectively of the field which has been passed as a parameter. However, note that neither of these work if you have a [[Creating_a_custom_form_field_type|Custom Field]]. Also note that these Form methods  are different from the &amp;lt;tt&amp;gt;getInput()&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;getLabel()&amp;lt;/tt&amp;gt; FormField methods which you have to provide when you are setting up some types of Custom Fields. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;getValue()&amp;lt;/tt&amp;gt; returns the value of the field you pass as a parameter, reading this from the data passed in the &amp;lt;tt&amp;gt;bind()&amp;lt;/tt&amp;gt; call. It doesn&#039;t take account of the &amp;lt;tt&amp;gt;default&amp;lt;/tt&amp;gt; attribute set against the field, which will get converted into the HTML field value attribute if no pre-fill data for that field is provided.&lt;br /&gt;
&lt;br /&gt;
== Sample Component Code ==&lt;br /&gt;
Below are 6 files which constitute a small component which you can install and run to demonstrate a number of the features described above, and which you can adapt to experiment with other features. &lt;br /&gt;
&lt;br /&gt;
Create the first 3 files in a folder &amp;quot;com_sample_form3&amp;quot;, and the second 3 files in a subdirectory of this &amp;quot;com_sample_form3/extra&amp;quot;. Then zip up the &amp;quot;com_sample_form3&amp;quot; folder to create &amp;lt;tt&amp;gt;com_sample_form3.zip&amp;lt;/tt&amp;gt; and install this as a component on your Joomla instance. Once installed navigate on your browser to your Joomla site and add the URL parameter &amp;lt;tt&amp;gt;&amp;amp;option=com_sample_form3&amp;lt;/tt&amp;gt;, which should display the form and allow you to enter data and submit the form. The comments in the code should make it clear what&#039;s going on.&lt;br /&gt;
&lt;br /&gt;
As described in the associated [[Basic form guide]], this isn&#039;t the best way to design a Joomla MVC component, but it&#039;s written this way to make the use of the &amp;lt;tt&amp;gt;Form&amp;lt;/tt&amp;gt; APIs as clear as possible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;com_sample_form3.xml&amp;lt;/tt&amp;gt; Manifest file for the component&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;component&amp;quot; version=&amp;quot;3.1.0&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;name&amp;gt;com_sample_form3&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;Sample form 3&amp;lt;/description&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;administration&amp;gt;&lt;br /&gt;
	&amp;lt;/administration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files folder=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;sample_form3.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;sample_form.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;extra&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sample_form.xml&amp;lt;/tt&amp;gt; File containing the XML for the form definition. The 3 fields are enclosed within a fieldset &amp;quot;mainFieldset&amp;quot;, and the email and telephone number fields are within a field group &amp;quot;details&amp;quot;. The message field has a custom validation &amp;quot;noasterisk&amp;quot;. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form name=&amp;quot;myFormName&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset name=&amp;quot;mainFieldset&amp;quot; label=&amp;quot;mainFieldsetLabel&amp;quot; description=&amp;quot;mainFieldsetDescription&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;field&lt;br /&gt;
			name=&amp;quot;message&amp;quot;&lt;br /&gt;
			type=&amp;quot;text&amp;quot;&lt;br /&gt;
			label=&amp;quot;Message&amp;quot;&lt;br /&gt;
			size=&amp;quot;40&amp;quot;&lt;br /&gt;
			validate=&amp;quot;noasterisk&amp;quot;&lt;br /&gt;
			class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
			required=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;fields name=&amp;quot;details&amp;quot;&amp;gt;&lt;br /&gt;
			&amp;lt;fieldset name=&amp;quot;detailsFieldset&amp;quot;&amp;gt;&lt;br /&gt;
				&amp;lt;field name=&amp;quot;email&amp;quot; &lt;br /&gt;
					type=&amp;quot;email&amp;quot;&lt;br /&gt;
					label=&amp;quot;Email&amp;quot;&lt;br /&gt;
					required=&amp;quot;true&amp;quot;&lt;br /&gt;
					size=&amp;quot;40&amp;quot;&lt;br /&gt;
					class=&amp;quot;inputbox&amp;quot; /&amp;gt;&lt;br /&gt;
			&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
			&amp;lt;field name=&amp;quot;telephone&amp;quot; &lt;br /&gt;
				type=&amp;quot;tel&amp;quot;&lt;br /&gt;
				label=&amp;quot;Telephone number&amp;quot;&lt;br /&gt;
				required=&amp;quot;true&amp;quot;&lt;br /&gt;
				size=&amp;quot;40&amp;quot;&lt;br /&gt;
				class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
				validate=&amp;quot;tel&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;/fields&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;sample_form3.php&amp;lt;/tt&amp;gt; The main code file which is run when an HTTP GET or POST is directed towards this component. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Form\Form;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
// base form definition&lt;br /&gt;
$form = Form::getInstance(&amp;quot;sample&amp;quot;, __DIR__ . &amp;quot;/sample_form.xml&amp;quot;, array(&amp;quot;control&amp;quot; =&amp;gt; &amp;quot;myform&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
// because email and telephone are within the &amp;quot;details&amp;quot; group, prefill data needs to reflect that&lt;br /&gt;
$prefillData = array(&amp;quot;details&amp;quot; =&amp;gt; array(&amp;quot;email&amp;quot; =&amp;gt; &amp;quot;.@.&amp;quot;, &amp;quot;telephone&amp;quot; =&amp;gt; &amp;quot;0&amp;quot;), &amp;quot;time&amp;quot; =&amp;gt; &amp;quot;12:34&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// add form and field paths (rule path added later, before validation in HTTP POST handling)&lt;br /&gt;
Form::addFieldPath(__DIR__ . &amp;quot;/extra&amp;quot;);&lt;br /&gt;
Form::addFormPath(__DIR__ . &amp;quot;/extra&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// using xpath parameter include just the &amp;quot;time&amp;quot; field from extra_form.xml, not the &amp;quot;ignored&amp;quot; field&lt;br /&gt;
$extraForm = $form-&amp;gt;loadFile(&amp;quot;extra_form&amp;quot;, true, &amp;quot;//field[@name=&#039;time&#039;]&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// add a new element to the form, into &amp;quot;details&amp;quot; group and &amp;quot;mainFieldset&amp;quot; fieldset&lt;br /&gt;
$xml = new SimpleXMLElement(&#039;&amp;lt;field name=&amp;quot;upload&amp;quot; type=&amp;quot;file&amp;quot; label=&amp;quot;Photo&amp;quot; accept=&amp;quot;image/*&amp;quot; /&amp;gt;&#039;);&lt;br /&gt;
$form-&amp;gt;setField($xml, &#039;details&#039;, true, &amp;quot;mainFieldset&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Change label on message field to say &amp;quot;Description&amp;quot; and set hint (html placeholder) to be &amp;quot;No asterisks!&amp;quot;&lt;br /&gt;
$form-&amp;gt;setFieldAttribute(&amp;quot;message&amp;quot;, &amp;quot;label&amp;quot;, &amp;quot;Description&amp;quot;);&lt;br /&gt;
$form-&amp;gt;setFieldAttribute(&amp;quot;message&amp;quot;, &amp;quot;hint&amp;quot;, &amp;quot;No asterisks!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Remove telephone field - uncomment line below to activate&lt;br /&gt;
// $form-&amp;gt;removeField(&amp;quot;telephone&amp;quot;, &amp;quot;details&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// Some reflection methods&lt;br /&gt;
echo &amp;quot;&amp;lt;h2&amp;gt;Reflection methods output&amp;lt;/h2&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$formName = $form-&amp;gt;getAttribute(&amp;quot;name&amp;quot;);&lt;br /&gt;
echo &amp;quot;Form name is: $formName&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$formControl = $form-&amp;gt;getFormControl();&lt;br /&gt;
echo &amp;quot;Form control is: $formControl&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$detailsGroup = $form-&amp;gt;getGroup(&#039;details&#039;);&lt;br /&gt;
echo &amp;quot;Fields in details group: &amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
foreach ($detailsGroup as $key =&amp;gt; $value)&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;Key is: $key, PHP class of field is &amp;quot; . get_class($value) . &amp;quot;, and name attribute is &amp;quot; . $value-&amp;gt;getAttribute(&amp;quot;name&amp;quot;) . &amp;quot;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$fieldsets = $form-&amp;gt;getFieldsets();&lt;br /&gt;
echo &amp;quot;Fieldset label for mainFieldset is &amp;quot; . $fieldsets[&#039;mainFieldset&#039;]-&amp;gt;label . &amp;quot;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
if ($_SERVER[&#039;REQUEST_METHOD&#039;] === &#039;POST&#039;) &lt;br /&gt;
{&lt;br /&gt;
	$app   = Factory::getApplication();&lt;br /&gt;
	$data = $app-&amp;gt;input-&amp;gt;post-&amp;gt;get(&#039;myform&#039;, array(), &amp;quot;array&amp;quot;);&lt;br /&gt;
	echo &amp;quot;&amp;lt;h2&amp;gt;POST data&amp;lt;/h2&amp;gt;&amp;quot;;&lt;br /&gt;
	echo &amp;quot;Message was &amp;quot; . $data[&amp;quot;message&amp;quot;] . &lt;br /&gt;
		&amp;quot;, email was &amp;quot; . $data[&amp;quot;details&amp;quot;][&amp;quot;email&amp;quot;] . &lt;br /&gt;
		&amp;quot;, and time was &amp;quot; . $data[&amp;quot;time&amp;quot;] . &amp;quot;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	// add rule path for validation &lt;br /&gt;
	Form::addRulePath(__DIR__ . &amp;quot;/extra&amp;quot;);&lt;br /&gt;
	$filteredData = $form-&amp;gt;filter($data);&lt;br /&gt;
	$result = $form-&amp;gt;validate($filteredData);&lt;br /&gt;
	if ($result)&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;Validation passed ok&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;Validation failed&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
		$errors = $form-&amp;gt;getErrors();&lt;br /&gt;
		foreach ($errors as $error)&lt;br /&gt;
		{&lt;br /&gt;
			echo $error-&amp;gt;getMessage() . &amp;quot;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
		}&lt;br /&gt;
		// in the redisplayed form show what the user entered (after data is filtered)&lt;br /&gt;
		$prefillData = $filteredData;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$form-&amp;gt;bind($prefillData);&lt;br /&gt;
$data = $form-&amp;gt;getData();&lt;br /&gt;
echo &amp;quot;&amp;lt;br&amp;gt;Form data is: $data&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;&amp;lt;?php echo JRoute::_(&#039;index.php?option=com_sample_form3&#039;); ?&amp;gt;&amp;quot;&lt;br /&gt;
    method=&amp;quot;post&amp;quot; name=&amp;quot;sampleForm&amp;quot; id=&amp;quot;adminForm&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;h2&amp;gt;mainFieldset fieldset&amp;lt;/h2&amp;gt;&lt;br /&gt;
	&amp;lt;?php echo $form-&amp;gt;renderFieldset(&#039;mainFieldset&#039;);  ?&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;h2&amp;gt;time field&amp;lt;/h2&amp;gt;&lt;br /&gt;
	&amp;lt;?php echo $form-&amp;gt;renderField(&#039;time&#039;);  ?&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;h2&amp;gt;ignored field - should be blank&amp;lt;/h2&amp;gt;&lt;br /&gt;
	&amp;lt;?php echo $form-&amp;gt;renderField(&#039;ignored&#039;);  ?&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;Submit&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;extra/extra_form.xml&amp;lt;/tt&amp;gt; The form definition for the additional form fields to be added to the form. The component code includes just the &amp;quot;time&amp;quot; field from this form definition, and this is a [[Creating a custom form field type|custom field]] of type &amp;quot;mytime&amp;quot;. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form&amp;gt;&lt;br /&gt;
	&amp;lt;field&lt;br /&gt;
		name=&amp;quot;ignored&amp;quot;&lt;br /&gt;
		type=&amp;quot;number&amp;quot;&lt;br /&gt;
		label=&amp;quot;Number&amp;quot;&lt;br /&gt;
		step=&amp;quot;0.1&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;field name=&amp;quot;time&amp;quot; &lt;br /&gt;
		type=&amp;quot;mytime&amp;quot;&lt;br /&gt;
		label=&amp;quot;Enter time&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;extra/Mytime.php&amp;lt;/tt&amp;gt; This provides the &amp;lt;tt&amp;gt;&amp;lt;input&amp;gt;&amp;lt;/tt&amp;gt; HTML element for the &amp;quot;mytime&amp;quot; custom field. As there is no &amp;lt;tt&amp;gt;getLabel()&amp;lt;/tt&amp;gt; method here, the label will be taken from the form field definition XML. &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;JPATH_PLATFORM&#039;) or die;&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
use Joomla\CMS\Form\FormField;&lt;br /&gt;
&lt;br /&gt;
class JFormFieldMytime extends FormField&lt;br /&gt;
{&lt;br /&gt;
	protected $type = &#039;Mytime&#039;;&lt;br /&gt;
&lt;br /&gt;
	protected function getInput()&lt;br /&gt;
	{&lt;br /&gt;
		// Set attributes - here just the CSS class for the input element, if specified&lt;br /&gt;
		$attr = !empty($this-&amp;gt;class) ? &#039; class=&amp;quot;&#039; . $this-&amp;gt;class . &#039;&amp;quot;&#039; : &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
		// set up html, including the value and other attributes&lt;br /&gt;
		$html = &#039;&amp;lt;input type=&amp;quot;time&amp;quot; name=&amp;quot;&#039; . $this-&amp;gt;name . &#039;&amp;quot; value=&amp;quot;&#039; . $this-&amp;gt;value . &#039;&amp;quot;&#039; . $attr . &#039;/&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
		return $html;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;extra/noasterisk.php&amp;lt;/tt&amp;gt; This provides the validation rule for the &amp;quot;noasterisk&amp;quot; custom validation for the message field.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
 &lt;br /&gt;
class JFormRuleNoasterisk extends JFormRule&lt;br /&gt;
{&lt;br /&gt;
	// regex to allow anything except an asterisk&lt;br /&gt;
	protected $regex = &#039;^[^\*]+$&#039;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Basic_form_guide&amp;diff=1033487</id>
		<title>Basic form guide</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Basic_form_guide&amp;diff=1033487"/>
		<updated>2024-11-27T10:41:26Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to the [https://manual.joomla.org/docs/general-concepts/forms/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This is one of a series of [[API Guides]], which aim to help you understand how to use the Joomla APIs through providing detailed explanations and sample code which you can easily install and run.&lt;br /&gt;
&lt;br /&gt;
The Joomla Form class and API enables you to easily develop HTML forms and handle the user&#039;s input.&lt;br /&gt;
&lt;br /&gt;
This page describes how you interact in general with the Joomla Form class and provides the code of a simple component which you can install to demonstrate use of this API. A companion guide [[Advanced form guide|Advanced Form Guide]] deals with more advanced aspects of the Joomla Form class.&lt;br /&gt;
&lt;br /&gt;
Joomla itself also has a specific way of designing form functionality, and this page includes tutorial material to help you understand and develop your component to align with these principles.&lt;br /&gt;
&lt;br /&gt;
== Overall Description ==&lt;br /&gt;
The diagram below shows the basic use of the Joomla Form class.&lt;br /&gt;
&lt;br /&gt;
[[File:basicform.jpg|Using Joomla Forms]]&lt;br /&gt;
&lt;br /&gt;
Firstly, you need to define your form in XML using Joomla [[Standard form field types]]. See the component code below for an example. In basic terms, each field element in your XML file maps to an HTML (mostly &amp;quot;input&amp;quot;) element in the form, with the XML field attributes mapping to the (input) element attributes. Many of the possible field attributes are listed in [[Text form field type]].&lt;br /&gt;
&lt;br /&gt;
=== Step 1 Loading the Form ===&lt;br /&gt;
The user clicks on the URL of your form, and Joomla routes the HTTP GET request through to your component code. You need to call &#039;&#039;Form::getInstance()&#039;&#039; passing the name of your XML file with your form definition. The Joomla Form code creates a Form instance, and then (in &#039;&#039;Form::loadFile()&#039;&#039;) reads the file into memory (as a PHP &#039;&#039;SimpleXMLElement&#039;&#039;) and parses the XML to ensure it&#039;s valid. The main parameters passed to &#039;&#039;getInstance()&#039;&#039; are:&lt;br /&gt;
* name – a string specifying the identity to give to this form – it just needs to be unique, so that it doesn&#039;t clash with any other Joomla forms on the same webpage&lt;br /&gt;
* data – the name of the XML file which has your form definition&lt;br /&gt;
* options – an array of options, with the &amp;quot;control&amp;quot; element specifying the name of the array which the POST parameters will be held in. For example, the sample code has &#039;&#039;array(&amp;quot;control&amp;quot;=&amp;gt;&amp;quot;myform&amp;quot;)&#039;&#039; which means that the HTML input elements will have name attributes set to &amp;quot;myform[message]&amp;quot;, &amp;quot;myform[email]&amp;quot;, etc,. They will be passed in POST parameters that way, and it&#039;s then very easy to get these into a PHP array.&lt;br /&gt;
&lt;br /&gt;
=== Step 2 Providing Pre-fill Data ===&lt;br /&gt;
You provide values for any form element you wish. For example, if this form is being used to edit a record in the database, then you would pre-populate it with existing field values from the database. You can provide values by setting up an associative array &#039;&#039;$data&#039;&#039; and passing it to &#039;&#039;Form::bind($data)&#039;&#039; method, and Joomla Form then stores this data locally within the Form instance.&lt;br /&gt;
&lt;br /&gt;
=== Step 3 Outputting the Form in HTML ===&lt;br /&gt;
You call &#039;&#039;renderField(fieldName)&#039;&#039; on the Form instance and you get returned the HTML which you can echo to the output. Joomla processes its XML representation of your form to obtain the section relating to the passed-in fieldName, generates the HTML for this HTML element and includes the &amp;quot;value&amp;quot; attribute based on the pre-populated data which you passed in step 2.&lt;br /&gt;
When outputting the form you also need to surround the input elements in a &#039;&#039;&amp;lt;form&amp;gt;&#039;&#039; element and add a submit button.&lt;br /&gt;
&lt;br /&gt;
=== Step 4 User Submitting the Form ===&lt;br /&gt;
The user enters data into your HTML form and clicks on the submit button. The browser generates an HTTP POST request to the URL specified in the &#039;&#039;&amp;lt;form&amp;gt;&#039;&#039; element and passes to the server in POST parameters the values entered by the user; each parameter keyed by the &amp;quot;name&amp;quot; attribute of the HTML input element.&lt;br /&gt;
&lt;br /&gt;
Joomla routes this POST through to your component. As this is a new HTTP request the previous Form instance no longer exists, so you have to again call &#039;&#039;Form::getInstance()&#039;&#039;, passing the filename of your form XML, and Joomla (as before) creates a Form instance and reads this file into memory.&lt;br /&gt;
&lt;br /&gt;
=== Step 5 Handling the HTTP POST Data ===&lt;br /&gt;
In this step you process the submitted data. This involves:&lt;br /&gt;
# Getting the POST data using &#039;&#039;Factory::getApplication-&amp;gt;input-&amp;gt;get()&#039;&#039;. Usually the &amp;quot;name&amp;quot; attributes of the input elements are defined so that the POST parameters appear as an array, and you can use the ARRAY filter from [[Retrieving_request_data_using_JInput]] to read these directly into a PHP array. However, this means that the individual elements are not filtered at all.&lt;br /&gt;
# Filtering. This applies filtering on each of the input values. The filter applied to a field is governed by the &amp;quot;filter=...&amp;quot; attribute on that field in your form XML file, or if not present then the default filter will remove HTML tags etc from your data values. The possible filters are in the &#039;&#039;filterField()&#039;&#039; method of the Form class (and see https://joomla.stackexchange.com/questions/5764/what-are-possible-filters-in-joomla-form-fields). Note that these form field filters are different from the jinput filters.&lt;br /&gt;
# Validation. You validate the data which the user has entered by calling validate($data) on your Form instance, passing an associative array of the (filtered) user data. Joomla compares the user-entered data with the validation you defined in your form XML file, and generates errors for fields which fail the validation.&lt;br /&gt;
&lt;br /&gt;
If there are validation errors then you should display those errors to the user, and redisplay the form, pre-populating the fields with the (filtered) data which the user entered previously.&lt;br /&gt;
&lt;br /&gt;
If there are no errors then you can confirm this to the user, and show the next web page.&lt;br /&gt;
&lt;br /&gt;
== Sample Form 1 ==&lt;br /&gt;
Below is the code for a small component which you can install to demonstrate basic use of Joomla forms. Place the following 3 files into a folder called &amp;quot;com_sample_form1&amp;quot;. Then zip up the folder to create &#039;&#039;com_sample_form1.zip&#039;&#039; and install this as a component on your Joomla instance.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_sample_form1.xml&#039;&#039; Manifest file for the component&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;component&amp;quot; version=&amp;quot;3.1.0&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;name&amp;gt;com_sample_form1&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;Sample form 1&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;administration&amp;gt;&lt;br /&gt;
	&amp;lt;/administration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files folder=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;sample_form1.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;sample_form.xml&amp;lt;/filename&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;sample_form.xml&#039;&#039; File containing the XML for the form definition&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form&amp;gt;&lt;br /&gt;
	&amp;lt;field&lt;br /&gt;
		name=&amp;quot;message&amp;quot;&lt;br /&gt;
		type=&amp;quot;text&amp;quot;&lt;br /&gt;
		label=&amp;quot;Enter message&amp;quot;&lt;br /&gt;
		size=&amp;quot;40&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;field name=&amp;quot;email&amp;quot;&lt;br /&gt;
		type=&amp;quot;email&amp;quot;&lt;br /&gt;
		label=&amp;quot;Enter email&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot;&lt;br /&gt;
		size=&amp;quot;40&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;field name=&amp;quot;telephone&amp;quot;&lt;br /&gt;
		type=&amp;quot;tel&amp;quot;&lt;br /&gt;
		label=&amp;quot;Enter telephone number&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot;&lt;br /&gt;
		size=&amp;quot;40&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
		validate=&amp;quot;tel&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;sample_form1.php&#039;&#039; Component code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Form\Form;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
$form = Form::getInstance(&amp;quot;sample&amp;quot;, __DIR__ . &amp;quot;/sample_form.xml&amp;quot;, array(&amp;quot;control&amp;quot; =&amp;gt; &amp;quot;myform&amp;quot;));&lt;br /&gt;
$prefillData = array(&amp;quot;email&amp;quot; =&amp;gt; &amp;quot;.@.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
if ($_SERVER[&#039;REQUEST_METHOD&#039;] === &#039;POST&#039;)&lt;br /&gt;
{&lt;br /&gt;
	$app   = JFactory::getApplication();&lt;br /&gt;
	$data = $app-&amp;gt;input-&amp;gt;post-&amp;gt;get(&#039;myform&#039;, array(), &amp;quot;array&amp;quot;);&lt;br /&gt;
	echo &amp;quot;Message was &amp;quot; . $data[&amp;quot;message&amp;quot;] .&lt;br /&gt;
		&amp;quot;, email was &amp;quot; . $data[&amp;quot;email&amp;quot;] .&lt;br /&gt;
		&amp;quot;, and telephone was &amp;quot; . $data[&amp;quot;telephone&amp;quot;] . &amp;quot;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	$filteredData = $form-&amp;gt;filter($data);&lt;br /&gt;
	$result = $form-&amp;gt;validate($filteredData);&lt;br /&gt;
	if ($result)&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;Validation passed ok&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;Validation failed&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
		$errors = $form-&amp;gt;getErrors();&lt;br /&gt;
		foreach ($errors as $error)&lt;br /&gt;
		{&lt;br /&gt;
			echo $error-&amp;gt;getMessage() . &amp;quot;&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
		}&lt;br /&gt;
		// in the redisplayed form show what the user entered (after data is filtered)&lt;br /&gt;
		$prefillData = $filteredData;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$form-&amp;gt;bind($prefillData);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;&amp;lt;?php echo JRoute::_(&#039;index.php?option=com_sample_form1&#039;); ?&amp;gt;&amp;quot;&lt;br /&gt;
    method=&amp;quot;post&amp;quot; name=&amp;quot;sampleForm&amp;quot; id=&amp;quot;adminForm&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;?php echo $form-&amp;gt;renderField(&#039;message&#039;);  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;?php echo $form-&amp;gt;renderField(&#039;email&#039;);  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;?php echo $form-&amp;gt;renderField(&#039;telephone&#039;);  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;button type=&amp;quot;submit&amp;quot;&amp;gt;Submit&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once installed navigate to your site and add the following parameter to the URL:&lt;br /&gt;
&#039;&#039;?option=com_sample_form1&#039;&#039;. You should then see the form displayed with 3 required fields:&lt;br /&gt;
* a general text input field for a message&lt;br /&gt;
* an email input field, pre-populated with the string &amp;quot;.@.&amp;quot;&lt;br /&gt;
* a telephone number input field.&lt;br /&gt;
and using your browser&#039;s development tools you can compare the HTML attributes with the attributes in your XML form definition.&lt;br /&gt;
&lt;br /&gt;
Note that modern browsers will do some validation on the values you enter, specifically they will validate the email address and will force you to enter something into fields with the &amp;quot;required&amp;quot; attribute set, but don&#039;t (currently) do validation on telephone number fields.&lt;br /&gt;
&lt;br /&gt;
Once you enter valid data into the fields and press Submit, then the data will be sent to the server and the POST leg of the sample code will be run. This runs the filtering and validation routines. If there are validation errors then the code outputs the error messages, and prefills the form with the data which the user entered before redisplaying it.&lt;br /&gt;
&lt;br /&gt;
== MVC and Other Considerations ==&lt;br /&gt;
The way that the code above is written isn&#039;t the best approach if you are developing a genuine Joomla component. Instead you should follow the way that the Joomla core code is designed, in particular splitting your component into controllers, models, views and layouts, and the revised component code in the section after this follows this approach. The remainder of this section describes these and other design decisions, which should make the sample code easier to understand.&lt;br /&gt;
&lt;br /&gt;
=== Joomla MVC Split ===&lt;br /&gt;
In general terms Joomla splits components into separate types of functionality:&lt;br /&gt;
* the controller contains the &amp;quot;business logic&amp;quot; of the application, including deciding what view and model to use&lt;br /&gt;
* the model provides access to the data&lt;br /&gt;
* the view decides what data is necessary for outputting on the web page and obtains this data from the model&lt;br /&gt;
* the layout outputs the HTML, and includes in the output the data which has been collated by the view. The layout runs within the context of the view, and so has direct access to the variables of the view code.&lt;br /&gt;
&lt;br /&gt;
=== Post/Request/Get Pattern ===&lt;br /&gt;
In Joomla all of the HTML output (such as the display of a form) is performed in response to an HTTP GET, following the https://en.wikipedia.org/wiki/Post/Redirect/Get pattern. The sample code above doesn&#039;t follow this pattern, but instead outputs the validation errors and re-displays the form in the response to the HTTP POST request.&lt;br /&gt;
&lt;br /&gt;
To follow the Joomla pattern, in the code which handles the POST we should include a HTTP GET redirect to the form URL. As that GET will then be a new HTTP request/response we must store in the user session the data to be shown when the form is redisplayed:&lt;br /&gt;
* the validation error messages are stored and output using the &#039;&#039;enqueueMessage()&#039;&#039; method (which stores data in the user session automatically for us)&lt;br /&gt;
* the user-entered data is stored using &#039;&#039;setUserState()&#039;&#039; and retrieved using &#039;&#039;getUserState()&#039;&#039;, and keyed by a &#039;&#039;context&#039;&#039; which should be unique to this form. The code which provides the data for the form &#039;&#039;bind()&#039;&#039; operation must first check using &#039;&#039;getUserState()&#039;&#039; if there is any prefill data in the session. And if the user enters data which successfully passes validation then &#039;&#039;setUserState()&#039;&#039; should be called to clear this prefill data in the session, otherwise it will appear whenever the user next displays the form.&lt;br /&gt;
&lt;br /&gt;
=== Separate Controllers ===&lt;br /&gt;
In response to a GET or POST, Joomla always runs the same component file, sample_form1.php in the sample component example above and the top-level sample_form2.php in the example below. The sample_form2.php code below follows the example of the core Joomla components, and has code which passes control to different methods in different controllers based on the value of the HTTP parameter &#039;&#039;task&#039;&#039;. This parameter is set by Joomla core javascript based on the submit button, e.g. in the example below:&lt;br /&gt;
&lt;br /&gt;
onclick=&amp;quot;Joomla.submitbutton(&#039;myform.submit&#039;)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The task parameter is in this example set to &amp;quot;myform.submit&amp;quot;. In general the task parameter is of the form &amp;quot;firstpart.secondpart&amp;quot; and for a component called &amp;quot;com_example&amp;quot; Joomla will try to run an instance method called &#039;&#039;secondpart()&#039;&#039; of a controller class &#039;&#039;ExampleControllerFirstpart&#039;&#039; in a file &#039;&#039;firstpart.php&#039;&#039; in the &#039;&#039;controllers&#039;&#039; directory.&lt;br /&gt;
&lt;br /&gt;
If the task parameter is not set then Joomla will try to run the &#039;&#039;display()&#039;&#039; method of the &#039;&#039;ExampleController&#039;&#039; class which it will expect to find in &#039;&#039;controller.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In terms of code:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;$controller = JControllerLegacy::getInstance(&#039;Sample_form2&#039;);&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
uses the &#039;&#039;task&#039;&#039; parameter to identify the appropriate controller file to include, and then creates an instance of that controller class.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;$controller-&amp;gt;execute($input-&amp;gt;getCmd(&#039;task&#039;));&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
executes the appropriate method (&#039;&#039;secondpart()&#039;&#039; - or in the case below, &#039;&#039;submit()&#039;&#039; - or &#039;&#039;display()&#039;&#039;) of that class.&lt;br /&gt;
&lt;br /&gt;
In this way controller functionality handling GETs (generally in the file &#039;&#039;controller.php&#039;&#039;) is separated from that handling POSTs (generally in the files in the &#039;&#039;controllers&#039;&#039; folder).&lt;br /&gt;
&lt;br /&gt;
=== Joomla MVC Classes ===&lt;br /&gt;
&lt;br /&gt;
Joomla provides feature-rich controller, view and model classes from which your component controllers, views and models can inherit. The model code below inherits from &#039;&#039;FormModel&#039;&#039; which shields somewhat the Joomla &#039;&#039;Form&#039;&#039; API. In this case our model calls &#039;&#039;FormModel::loadForm()&#039;&#039;, and this then executes a callback to our &#039;&#039;loadFormData()&#039;&#039; to provide the data to &#039;&#039;bind()&#039;&#039; to the form.&lt;br /&gt;
&lt;br /&gt;
You can also use &#039;&#039;FormController&#039;&#039; and &#039;&#039;AdminController&#039;&#039; classes, but these assume that your component is using a database table to store the data. The Joomla MVC Component Development tutorial takes this approach in [[J3.x:Developing an MVC Component/Adding backend actions]].&lt;br /&gt;
&lt;br /&gt;
=== Security Token ===&lt;br /&gt;
Joomla uses a security token on forms to prevent CSRF attacks (see https://en.wikipedia.org/wiki/Cross-site_request_forgery). The token is output in the layout file&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&amp;lt;?php echo JHtml::_(&#039;form.token&#039;); ?&amp;gt;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and checked within the controller handling the POST:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;$this-&amp;gt;checkToken();&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the token is found to be invalid then &#039;&#039;checkToken()&#039;&#039; outputs a warning and redirects the user back to the previous page.&lt;br /&gt;
&lt;br /&gt;
=== Client-side Validation ===&lt;br /&gt;
In addition to the server-side validation included through the form XML definition, Joomla also provides a way of including JavaScript which performs client-side validation on the browser. This is NOT included below, as it&#039;s deemed beyond the scope of this tutorial, but you can find details of it in [[J3.x:Developing an MVC Component/Adding verifications]] and [[Client-side_form_validation|Client-side form validation]].&lt;br /&gt;
&lt;br /&gt;
== Sample Form 2 ==&lt;br /&gt;
This second sample component incorporates the design decisions described above and structures the code according to the Joomla paradigm. The overall file structure is shown in the diagram below.&lt;br /&gt;
&lt;br /&gt;
[[File:Sample-form-files.jpg|Sample Form 2 file structure]].&lt;br /&gt;
&lt;br /&gt;
Starting at the bottom of this diagram and going upwards the file contents are:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_sample_form2/sample_form2.php&#039;&#039; Entry point for the component. This is the first file which Joomla runs.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
// Load the appropriate controller class&lt;br /&gt;
$controller = JControllerLegacy::getInstance(&#039;Sample_form2&#039;);&lt;br /&gt;
&lt;br /&gt;
$input = JFactory::getApplication()-&amp;gt;input;&lt;br /&gt;
// Run the task method, or display() if no task parameter&lt;br /&gt;
$controller-&amp;gt;execute($input-&amp;gt;getCmd(&#039;task&#039;));&lt;br /&gt;
&lt;br /&gt;
$controller-&amp;gt;redirect();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_sample_form2/controller.php&#039;&#039; The controller for handling HTTP GET requests&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
use Joomla\CMS\MVC\Controller\BaseController;&lt;br /&gt;
&lt;br /&gt;
class Sample_form2Controller extends BaseController&lt;br /&gt;
{&lt;br /&gt;
	// Joomla will look for this class within the controller.php file&lt;br /&gt;
	// It will (usually) call the display() method, and will find this is in the BaseController class&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_sample_form2/sample_form2.xml&#039;&#039; Manifest file for the component.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;component&amp;quot; version=&amp;quot;3.1.0&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;name&amp;gt;com_sample_form2&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;Sample form 2&amp;lt;/description&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;administration&amp;gt;&lt;br /&gt;
	&amp;lt;/administration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files folder=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;sample_form2.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;controller.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;folder&amp;gt;controllers&amp;lt;/folder&amp;gt;&lt;br /&gt;
        &amp;lt;folder&amp;gt;views&amp;lt;/folder&amp;gt;&lt;br /&gt;
        &amp;lt;folder&amp;gt;models&amp;lt;/folder&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_sample_form2/views/form/view.html.php&#039;&#039; View file for displaying the form. The controller &#039;&#039;display()&#039;&#039; function will create instances of the model and view, and call the view &#039;&#039;display()&#039;&#039; function below.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\MVC\View\HtmlView;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
class Sample_form2ViewForm extends HtmlView&lt;br /&gt;
{&lt;br /&gt;
	public function display($tpl = null)&lt;br /&gt;
	{&lt;br /&gt;
		if (!$this-&amp;gt;form = $this-&amp;gt;get(&#039;form&#039;))&lt;br /&gt;
		{&lt;br /&gt;
			echo &amp;quot;Can&#039;t load form&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
		parent::display($tpl);	// this will include the layout file edit.php&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_sample_form2/views/form/tmpl/edit.php&#039;&#039; Layout file for displaying the form&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;&amp;lt;?php echo JRoute::_(&#039;index.php?option=com_sample_form2&amp;amp;view=form&amp;amp;layout=edit&#039;); ?&amp;gt;&amp;quot;&lt;br /&gt;
    method=&amp;quot;post&amp;quot; name=&amp;quot;adminForm&amp;quot; id=&amp;quot;adminForm&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;?php echo $this-&amp;gt;form-&amp;gt;renderField(&#039;message&#039;);  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;?php echo $this-&amp;gt;form-&amp;gt;renderField(&#039;email&#039;);  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;?php echo $this-&amp;gt;form-&amp;gt;renderField(&#039;telephone&#039;);  ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;button type=&amp;quot;button&amp;quot; class=&amp;quot;btn btn-primary&amp;quot; onclick=&amp;quot;Joomla.submitbutton(&#039;myform.submit&#039;)&amp;quot;&amp;gt;Submit&amp;lt;/button&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;task&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;?php echo JHtml::_(&#039;form.token&#039;); ?&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_sample_form2/models/form.php&#039;&#039; Model associated with displaying the form. The view &#039;&#039;get(&#039;form&#039;)&#039;&#039; gets mapped to the model &#039;&#039;getForm()&#039;&#039; method call.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\MVC\Model\FormModel;&lt;br /&gt;
&lt;br /&gt;
class Sample_form2ModelForm extends FormModel&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
	public function getForm($data = array(), $loadData = true)&lt;br /&gt;
	{&lt;br /&gt;
		$form = $this-&amp;gt;loadForm(&lt;br /&gt;
			&#039;com_sample_form2.sample&#039;,  // just a unique name to identify the form&lt;br /&gt;
			&#039;sample_form&#039;,				// the filename of the XML form definition&lt;br /&gt;
										// Joomla will look in the models/forms folder for this file&lt;br /&gt;
			array(&lt;br /&gt;
				&#039;control&#039; =&amp;gt; &#039;jform&#039;,	// the name of the array for the POST parameters&lt;br /&gt;
				&#039;load_data&#039; =&amp;gt; $loadData	// will be TRUE&lt;br /&gt;
			)&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
		if (empty($form))&lt;br /&gt;
		{&lt;br /&gt;
            $errors = $this-&amp;gt;getErrors();&lt;br /&gt;
			throw new Exception(implode(&amp;quot;\n&amp;quot;, $errors), 500);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		return $form;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
    protected function loadFormData()&lt;br /&gt;
	{&lt;br /&gt;
		// Check the session for previously entered form data.&lt;br /&gt;
		$data = JFactory::getApplication()-&amp;gt;getUserState(&lt;br /&gt;
			&#039;com_sample_form2.sample&#039;,	// a unique name to identify the data in the session&lt;br /&gt;
			array(&amp;quot;telephone&amp;quot; =&amp;gt; &amp;quot;0&amp;quot;)	// prefill data if no data found in session&lt;br /&gt;
		);&lt;br /&gt;
&lt;br /&gt;
		return $data;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_sample_form2/models/forms/sample_form.xml&#039;&#039; XML file containing the form definition&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form&amp;gt;&lt;br /&gt;
	&amp;lt;field&lt;br /&gt;
		name=&amp;quot;message&amp;quot;&lt;br /&gt;
		type=&amp;quot;text&amp;quot;&lt;br /&gt;
		label=&amp;quot;Enter message&amp;quot;&lt;br /&gt;
		size=&amp;quot;40&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;field name=&amp;quot;email&amp;quot;&lt;br /&gt;
		type=&amp;quot;email&amp;quot;&lt;br /&gt;
		label=&amp;quot;Enter email&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot;&lt;br /&gt;
		size=&amp;quot;40&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;field name=&amp;quot;telephone&amp;quot;&lt;br /&gt;
		type=&amp;quot;tel&amp;quot;&lt;br /&gt;
		label=&amp;quot;Enter telephone number&amp;quot;&lt;br /&gt;
		required=&amp;quot;true&amp;quot;&lt;br /&gt;
		size=&amp;quot;40&amp;quot;&lt;br /&gt;
		class=&amp;quot;inputbox&amp;quot;&lt;br /&gt;
		validate=&amp;quot;tel&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;com_sample_form2/controllers/Myform.php&#039;&#039; Controller which handles the HTTP POST&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\MVC\Controller\BaseController;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
class Sample_form2ControllerMyform extends BaseController&lt;br /&gt;
{&lt;br /&gt;
	public function submit($key = null, $urlVar = null)&lt;br /&gt;
	{&lt;br /&gt;
		$this-&amp;gt;checkToken();&lt;br /&gt;
&lt;br /&gt;
		$app   = JFactory::getApplication();&lt;br /&gt;
		$model = $this-&amp;gt;getModel(&#039;form&#039;);&lt;br /&gt;
		$form = $model-&amp;gt;getForm($data, false);&lt;br /&gt;
		if (!$form)&lt;br /&gt;
		{&lt;br /&gt;
			$app-&amp;gt;enqueueMessage($model-&amp;gt;getError(), &#039;error&#039;);&lt;br /&gt;
			return false;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// name of array &#039;jform&#039; must match &#039;control&#039; =&amp;gt; &#039;jform&#039; line in the model code&lt;br /&gt;
		$data  = $this-&amp;gt;input-&amp;gt;post-&amp;gt;get(&#039;jform&#039;, array(), &#039;array&#039;);&lt;br /&gt;
&lt;br /&gt;
		// This is validate() from the FormModel class, not the Form class&lt;br /&gt;
		// FormModel::validate() calls both Form::filter() and Form::validate() methods&lt;br /&gt;
		$validData = $model-&amp;gt;validate($form, $data);&lt;br /&gt;
&lt;br /&gt;
		if ($validData === false)&lt;br /&gt;
		{&lt;br /&gt;
			$errors = $model-&amp;gt;getErrors();&lt;br /&gt;
&lt;br /&gt;
			foreach ($errors as $error)&lt;br /&gt;
			{&lt;br /&gt;
				if ($error instanceof \Exception)&lt;br /&gt;
				{&lt;br /&gt;
					$app-&amp;gt;enqueueMessage($error-&amp;gt;getMessage(), &#039;warning&#039;);&lt;br /&gt;
				}&lt;br /&gt;
				else&lt;br /&gt;
				{&lt;br /&gt;
					$app-&amp;gt;enqueueMessage($error, &#039;warning&#039;);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
&lt;br /&gt;
			// Save the form data in the session, using a unique identifier&lt;br /&gt;
			$app-&amp;gt;setUserState(&#039;com_sample_form2.sample&#039;, $data);&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			$app-&amp;gt;enqueueMessage(&amp;quot;Data successfully validated&amp;quot;, &#039;notice&#039;);&lt;br /&gt;
			// Clear the form data in the session&lt;br /&gt;
			$app-&amp;gt;setUserState(&#039;com_sample_form2.sample&#039;, null);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		// Redirect back to the form in all cases&lt;br /&gt;
		$this-&amp;gt;setRedirect(JRoute::_(&#039;index.php?option=com_sample_form2&amp;amp;view=form&amp;amp;layout=edit&#039;, false));&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After creating the files as described above, zip up the &#039;&#039;com_sample_form2&#039;&#039; folder to create com_sample_form2.zip and install this component. Then navigate to your Joomla site and add into the URL the parameters &#039;&#039;&amp;amp;option=com_sample_form2&amp;amp;view=form&amp;amp;layout=edit&#039;&#039;. This should display the form, and should work in a similar fashion to previous sample form, except that errors etc. will appear in the message part of the Joomla display.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Module Development]]&lt;br /&gt;
[[Category:Plugin Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Inserting,_Updating_and_Removing_data_using_JDatabase&amp;diff=1033486</id>
		<title>Inserting, Updating and Removing data using JDatabase</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Inserting,_Updating_and_Removing_data_using_JDatabase&amp;diff=1033486"/>
		<updated>2024-11-27T10:38:50Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/database/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{Joomla version|version=3.x}}{{Joomla version|version=2.5|status=eos}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{-}}&lt;br /&gt;
{{tip|&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Note many examples online use &amp;lt;code&amp;gt;$db-&amp;gt;query()&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;$db-&amp;gt;execute()&amp;lt;/code&amp;gt;. This was the old method in Joomla 1.5 and 2.5 and will throw a deprecated notice in Joomla 3.0+.&amp;lt;/translate&amp;gt;|title=&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
Version Note&amp;lt;/translate&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
This tutorial is split into two independent parts:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* Inserting, updating and removing data from the database.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* Selecting data from one or more tables and retrieving it in a variety of forms.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
This section examines inserting, updating and removing data from a database table. See also the [[S:MyLanguage/Selecting_data_using_JDatabase|other part]].&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Introduction== &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Joomla provides a sophisticated database abstraction layer to simplify the usage for third party developers. New versions of the Joomla Platform API provide additional functionality which extends the database layer further and includes features such as connectors to a greater variety of database servers and the query chaining to improve readability of connection code and simplify SQL coding.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Joomla can use different kinds of SQL database systems and run in a variety of environments with different table-prefixes. In addition to these functions, the class automatically creates the database connection. Besides instantiating the object you need just two lines of code to get a result from the database in a variety of formats. Using the Joomla database layer ensures a maximum of compatibility and flexibility for your extension.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==The Query== &amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Joomla&#039;s database querying has changed since the new Joomla Framework was introduced  &#039;&#039;query chaining&#039;&#039; is now the recommended method for building database queries (although string queries are still supported).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
Query chaining refers to a method of connecting a number of methods, one after the other, with each method returning an object that can support the next method, improving readability and simplifying code.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
To obtain a new instance of the JDatabaseQuery class we use the JDatabaseDriver getQuery method:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Use one of the following depending on the file and version of Joomla &lt;br /&gt;
$db = $this-&amp;gt;_db; // use in Table class, also works in Model classes, J4 onwards&lt;br /&gt;
$db = $this-&amp;gt;getDatabase(); // only works in the Field, Model or Table classes, J4 onwards&lt;br /&gt;
&lt;br /&gt;
$db = JFactory::getDbo(); //deprecated J3, removed in J4 &lt;br /&gt;
$db = Factory::getDbo(); //deprecated J4 - requires use Joomla\CMS\Factory;&lt;br /&gt;
$db = $this-&amp;gt;getDbo(); // only works in the model or table classes, deprecated J5, use $this-&amp;gt;getDatabse();&lt;br /&gt;
$db = Factory::getContainer()-&amp;gt;get(&#039;DatabaseDriver&#039;); // Not well documented &lt;br /&gt;
&lt;br /&gt;
$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
The &#039;&#039;JDatabaseDriver::getQuery&#039;&#039; takes an optional argument, &#039;&#039;$new&#039;&#039;, which can be true or false (the default being false).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
To query our data source we can call a number of JDatabaseQuery methods; these methods encapsulate the data source&#039;s query language (in most cases SQL), hiding query-specific syntax from the developer and increasing the portability of the developer&#039;s source code.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
Some of the more frequently used methods include: select, from, join, where and order. There are also methods such as insert, update and delete for modifying records in the data store. By chaining these and other method calls, you can create almost any query against your data store without compromising portability of your code.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Inserting a Record== &amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
===Using SQL=== &amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
The JDatabaseQuery class provides a number of methods for building insert queries, the most common being insert, columns, values.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Get a db connection.&lt;br /&gt;
$db = JFactory::getDbo(); //deprecated J3, removed in J4 &lt;br /&gt;
$db = Factory::getDbo(); //deprecated J4 - requires use Joomla\CMS\Factory;&lt;br /&gt;
$db = $this-&amp;gt;getDbo(); // only works in the model or table classes, deprecated J4&lt;br /&gt;
$db = Factory::getContainer()-&amp;gt;get(&#039;DatabaseDriver&#039;); //J4 onwards, outside of the Model or Table  &lt;br /&gt;
$db = $this-&amp;gt;_db; //only works in the model or table classes, J4 onwards&lt;br /&gt;
&lt;br /&gt;
// Create a new query object.&lt;br /&gt;
$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
// Insert columns.&lt;br /&gt;
$columns = array(&#039;user_id&#039;, &#039;profile_key&#039;, &#039;profile_value&#039;, &#039;ordering&#039;);&lt;br /&gt;
&lt;br /&gt;
// Insert values.&lt;br /&gt;
$values = array(1001, $db-&amp;gt;quote(&#039;custom.message&#039;), $db-&amp;gt;quote(&#039;Inserting a record using insert()&#039;), 1);&lt;br /&gt;
&lt;br /&gt;
// Prepare the insert query.&lt;br /&gt;
$query&lt;br /&gt;
    -&amp;gt;insert($db-&amp;gt;quoteName(&#039;#__user_profiles&#039;))&lt;br /&gt;
    -&amp;gt;columns($db-&amp;gt;quoteName($columns))&lt;br /&gt;
    -&amp;gt;values(implode(&#039;,&#039;, $values));&lt;br /&gt;
&lt;br /&gt;
// Set the query using our newly populated query object and execute it.&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$db-&amp;gt;execute();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
(Here the &#039;&#039;quoteName()&#039;&#039; function adds appropriate quotes around the table and column names to avoid conflicts with any database reserved word, now or in the future.)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
To get the ID of the row that you just inserted, you can use the &#039;&#039;insertid&#039;&#039; method, for example.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Get the row that was just inserted&lt;br /&gt;
$new_row_id = $db-&amp;gt;insertid();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
====How to Store Empty Value as NULL==== &amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
If your default value of a column is NULL, you should not add that column name in the array. Let the database system store NULL as the default value.&lt;br /&gt;
If the default value of a column is not NULL and it is allowed to store NULL values, you should specify that in the code. See how to do it in the following example.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Get a db connection.&lt;br /&gt;
$db = JFactory::getDbo();&lt;br /&gt;
&lt;br /&gt;
// Create a new query object.&lt;br /&gt;
$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
/** First Case [NULL as default value] **/&lt;br /&gt;
// The column &#039;profile_value&#039; has NULL as default value. So, we will not add it to the array. The database engine will store NULL as value for column &#039;profile_value&#039;.&lt;br /&gt;
// $columns = array(&#039;user_id&#039;, &#039;profile_key&#039;, &#039;profile_value&#039;, &#039;ordering&#039;);&lt;br /&gt;
$columns = array(&#039;user_id&#039;, &#039;profile_key&#039;, &#039;ordering&#039;);&lt;br /&gt;
&lt;br /&gt;
// Insert values.&lt;br /&gt;
$values = array(1001, $db-&amp;gt;quote(&#039;custom.message&#039;), 1);&lt;br /&gt;
&lt;br /&gt;
/** Second Case [string as default value and you can also store NULL value] **/&lt;br /&gt;
// The column &#039;profile_value&#039; has empty string &#039;&#039; as default value but we can also store NULL value. So, we have to add the column name and NULL value to $columns and $values.&lt;br /&gt;
$columns = array(&#039;user_id&#039;, &#039;profile_key&#039;, &#039;profile_value&#039;, &#039;ordering&#039;);&lt;br /&gt;
&lt;br /&gt;
// Insert values.&lt;br /&gt;
$values = array(1001, $db-&amp;gt;quote(&#039;custom.message&#039;), $db-&amp;gt;quote(&#039;NULL&#039;), 1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
===Using an Object=== &amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
The &#039;&#039;JDatabaseDriver&#039;&#039; class also provides a convenient method for saving an object directly to the database allowing us to add a record to a table without writing a single line of SQL.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create and populate an object.&lt;br /&gt;
$profile = new stdClass();&lt;br /&gt;
$profile-&amp;gt;user_id = 1001;&lt;br /&gt;
$profile-&amp;gt;profile_key=&#039;custom.message&#039;;&lt;br /&gt;
$profile-&amp;gt;profile_value=&#039;Inserting a record using insertObject()&#039;;&lt;br /&gt;
$profile-&amp;gt;ordering=1;&lt;br /&gt;
&lt;br /&gt;
// Insert the object into the user profile table.&lt;br /&gt;
$result = JFactory::getDbo()-&amp;gt;insertObject(&#039;#__user_profiles&#039;, $profile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
Notice here that we do not need to escape the table name; the insertObject method does this for us.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
The insertObject method will throw a error if there is a problem inserting the record into the database table.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
If you are providing a unique primary key value (as in the example above), it is highly recommended that you select from the table by that column value before attempting an insert.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
If you are simply inserting the next row in your table (i.e. the database generates a primary key value), you can specify the primary key column-name as the third parameter of the insertObject() method and the method will update the object with the newly generated primary key value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:39--&amp;gt;&lt;br /&gt;
For example, given the following statement:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=php&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$result = $dbconnect-&amp;gt;insertObject(&#039;#__my_table&#039;, $object, &#039;primary_key&#039;); &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:40--&amp;gt;&lt;br /&gt;
after execution, $object-&amp;gt;primary_key will be updated with the newly inserted row&#039;s primary key value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;HINT&#039;&#039;&#039; Set $object-&amp;gt;primary_key to null or 0 (zero) before inserting.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
====How to Store Empty Value as NULL When Inserting an Object==== &amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
If your default value of a column is NULL, you should not add that column name to the object. Let the database system store NULL as the default value.&lt;br /&gt;
If the default value of a column is not NULL and it is allowed to store NULL values, you should specify that in the code. See how to do it in the following example.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Create and populate an object.&lt;br /&gt;
$profile = new stdClass();&lt;br /&gt;
$profile-&amp;gt;user_id = 1001;&lt;br /&gt;
$profile-&amp;gt;profile_key=&#039;custom.message&#039;;&lt;br /&gt;
$profile-&amp;gt;ordering=1;&lt;br /&gt;
&lt;br /&gt;
/** First Case [NULL as default value] **/&lt;br /&gt;
// The column &#039;profile_value&#039; has NULL as default value. So, we will not add it to the object. The database engine will store NULL as value for column &#039;profile_value&#039;.&lt;br /&gt;
// $profile-&amp;gt;profile_value=&#039;Inserting a record using insertObject()&#039;;&lt;br /&gt;
&lt;br /&gt;
/** Second Case [string as default value and you can also store NULL value] **/&lt;br /&gt;
// The column &#039;profile_value&#039; has empty string &#039;&#039; as default value but we can also store NULL value. So, we have to add the column name and NULL value as its value.&lt;br /&gt;
$profile-&amp;gt;profile_value = $db-&amp;gt;quote(&#039;NULL&#039;);&lt;br /&gt;
&lt;br /&gt;
// Insert the object into the user profile table.&lt;br /&gt;
$result = JFactory::getDbo()-&amp;gt;insertObject(&#039;#__user_profiles&#039;, $profile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Updating a Record== &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
===Using SQL=== &amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
The [https://api.joomla.org/cms-3/classes/JDatabaseQuery.html JDatabaseQuery] class also provides methods for building update queries, in particular [https://api.joomla.org/cms-3/classes/JDatabaseQuery.html#method_update update] and [https://api.joomla.org/cms-3/classes/JDatabaseQuery.html#method_set set]. We also reuse another method which we used when creating select statements, the &#039;&#039;where&#039;&#039; method.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$db = JFactory::getDbo();&lt;br /&gt;
&lt;br /&gt;
$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
// Fields to update.&lt;br /&gt;
$fields = array(&lt;br /&gt;
    $db-&amp;gt;quoteName(&#039;profile_value&#039;) . &#039; = &#039; . $db-&amp;gt;quote(&#039;Updating custom message for user 1001.&#039;),&lt;br /&gt;
    $db-&amp;gt;quoteName(&#039;ordering&#039;) . &#039; = 2&#039;,&lt;br /&gt;
&lt;br /&gt;
    // If you would like to store NULL value, you should specify that.&lt;br /&gt;
    $db-&amp;gt;quoteName(&#039;avatar&#039;) . &#039; = NULL&#039;,&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
// Conditions for which records should be updated.&lt;br /&gt;
$conditions = array(&lt;br /&gt;
    $db-&amp;gt;quoteName(&#039;user_id&#039;) . &#039; = 42&#039;, &lt;br /&gt;
    $db-&amp;gt;quoteName(&#039;profile_key&#039;) . &#039; = &#039; . $db-&amp;gt;quote(&#039;custom.message&#039;)&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
$query-&amp;gt;update($db-&amp;gt;quoteName(&#039;#__user_profiles&#039;))-&amp;gt;set($fields)-&amp;gt;where($conditions);&lt;br /&gt;
&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
$result = $db-&amp;gt;execute();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== Using an Object === &amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
Like &#039;&#039;insertObject&#039;&#039;, the JDatabaseDriver class provides a convenient method for updating an object.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
Below we will update our custom table with new values using an existing id primary key:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$updateNulls = true;&lt;br /&gt;
&lt;br /&gt;
// Create an object for the record we are going to update.&lt;br /&gt;
$object = new stdClass();&lt;br /&gt;
&lt;br /&gt;
// Must be a valid primary key value.&lt;br /&gt;
$object-&amp;gt;id = 1;&lt;br /&gt;
$object-&amp;gt;title = &#039;My Custom Record&#039;;&lt;br /&gt;
$object-&amp;gt;description = &#039;A custom record being updated in the database.&#039;;&lt;br /&gt;
&lt;br /&gt;
// If you would like to store NULL value, you should specify that.&lt;br /&gt;
$object-&amp;gt;short_description = null;&lt;br /&gt;
&lt;br /&gt;
// Update their details in the users table using id as the primary key.&lt;br /&gt;
// You should provide forth parameter with value TRUE, if you would like to store the NULL values.&lt;br /&gt;
$result = JFactory::getDbo()-&amp;gt;updateObject(&#039;#__custom_table&#039;, $object, &#039;id&#039;, $updateNulls);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
Just like insertObject, updateObject takes care of escaping table names for us.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
The updateObject method will throw a error if there is a problem updating the record into the database table.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
We need to ensure that the record already exists before attempting to update it, so we would probably add some kind of record check before executing the updateObject method.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Deleting a Record== &amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
Finally, there is also a delete method to remove records from the database.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$db = JFactory::getDbo();&lt;br /&gt;
&lt;br /&gt;
$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
// delete all custom keys for user 1001.&lt;br /&gt;
$conditions = array(&lt;br /&gt;
    $db-&amp;gt;quoteName(&#039;user_id&#039;) . &#039; = 1001&#039;, &lt;br /&gt;
    $db-&amp;gt;quoteName(&#039;profile_key&#039;) . &#039; = &#039; . $db-&amp;gt;quote(&#039;custom.%&#039;)&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
$query-&amp;gt;delete($db-&amp;gt;quoteName(&#039;#__user_profiles&#039;));&lt;br /&gt;
$query-&amp;gt;where($conditions);&lt;br /&gt;
&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
$result = $db-&amp;gt;execute();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Sample Module Code == &amp;lt;!--T:43--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:44--&amp;gt;&lt;br /&gt;
Below is the code for a simple Joomla module which you can install and run to demonstrate use of the JDatabase functionality for updating records in the database and which you can adapt to experiment with some of the concepts described above. If you are unsure about development and installing a Joomla module then following the tutorial at [[S:MyLanguage/J3.x:Creating a simple module/Introduction| Creating a simple module]] will help.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:45--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Important note: In any Joomla extensions which you develop that you should avoid accessing the core Joomla tables directly like this and should instead use the Joomla APIs if at all possible. The database structures may change without warning.&#039;&#039;&#039;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
In a folder &#039;&#039;mod_db_update&#039;&#039; create these two files:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;mod_db_update.xml&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.1&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;Database update demo&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.1&amp;lt;/version&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Code demonstrating use of Joomla Database class to perform SQL UPDATE statements&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_db_update&amp;quot;&amp;gt;mod_db_update.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;mod_db_update.php&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted Access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
$db = Factory::getDbo();&lt;br /&gt;
&lt;br /&gt;
$me = Factory::getUser();&lt;br /&gt;
&lt;br /&gt;
if ($me-&amp;gt;id == 0)&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;Not logged on!&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	$email = $me-&amp;gt;email; &lt;br /&gt;
	// change the case of the email address&lt;br /&gt;
	$email_uppercase = strtoupper($email);&lt;br /&gt;
	if ($email == $email_uppercase)&lt;br /&gt;
	{&lt;br /&gt;
		$new_email = strtolower($email);&lt;br /&gt;
	}&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
		$new_email = $email_uppercase;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
	$fields = array($db-&amp;gt;quoteName(&#039;email&#039;) . &amp;quot; = &#039;{$new_email}&#039;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	$conditions = array($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; = &#039; . $me-&amp;gt;id); &lt;br /&gt;
&lt;br /&gt;
	$query-&amp;gt;update($db-&amp;gt;quoteName(&#039;#__users&#039;))-&amp;gt;set($fields)-&amp;gt;where($conditions);&lt;br /&gt;
&lt;br /&gt;
	echo $db-&amp;gt;replacePrefix((string) $query);&lt;br /&gt;
	&lt;br /&gt;
	$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
	if ($result = $db-&amp;gt;execute())&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;Email case successfully changed!&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
The code above updates the email address field in the &#039;&#039;users&#039;&#039; record of the currently logged-on user, toggling between upper case and lower case in successive reloads of the web page. &amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
The method &#039;&#039;Factory::getUser()&#039;&#039; returns the &#039;&#039;user&#039;&#039; object of the currently logged-on user, or if not logged on, then a blank &#039;&#039;user&#039;&#039; object, whose &#039;&#039;id&#039;&#039; field is set to zero. &amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
The &#039;&#039;$db-&amp;gt;replacePrefix((string) $query)&#039;&#039; expression returns the actual SQL statement and outputting this can be useful in debugging. &amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
Zip up the &#039;&#039;mod_db_update&#039;&#039; directory to create &#039;&#039;mod_db_update.zip&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
Within your Joomla administrator go to Install Extensions and via the Upload Package File tab. Upload this zip file to install this sample log module.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
Make this module visible by editing it (click on it within the Modules page) then:&lt;br /&gt;
# Make its status &#039;&#039;Published&#039;&#039;&lt;br /&gt;
# Select a position on the page for it to be shown&lt;br /&gt;
# Specify the pages it should appear on in the Menu Assignment tab&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
When you visit a site web page you should see the module in your selected position and it should output the SQL UPDATE statement and affirm that it has updated the record successfully. To confirm that it has updated the record correctly, go into PHPMyAdmin and view the &#039;&#039;users&#039;&#039; table within the Joomla database. The updates aren&#039;t visible via the admin Users functionality on the Backend; Joomla displays in lower case all the email addresses in the records.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
[[Category:Database]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Selecting_data_using_JDatabase&amp;diff=1033485</id>
		<title>Selecting data using JDatabase</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Selecting_data_using_JDatabase&amp;diff=1033485"/>
		<updated>2024-11-27T10:37:15Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/database/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{Joomla version|version=3.x}}{{Joomla version|version=2.5|status=eos}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{-}}&lt;br /&gt;
{{tip|&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Note many examples online use &amp;lt;code&amp;gt;$db-&amp;gt;query()&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;$db-&amp;gt;execute()&amp;lt;/code&amp;gt;. This was the old method in Joomla 1.5 and 2.5 and will throw a deprecated notice in Joomla 3.0+.&amp;lt;/translate&amp;gt;|title=&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
Version Note&amp;lt;/translate&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
This tutorial is split into two independent parts:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* Inserting, updating and removing data from the database.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* Selecting data from one or more tables and retrieving it in a variety of different forms&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
This section of the documentation looks at selecting data from a database table and retrieving it in a variety of formats. Also see the [[S:MyLanguage/Inserting,_Updating_and_Removing_data_using_JDatabase|Inserting, Updating and Removing Data using JDatabase article]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Introduction == &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Joomla provides a sophisticated database abstraction layer to simplify the usage for third party developers. New versions of the Joomla Platform API provide additional functionality which extends the database layer further, and includes features such as connectors to a greater variety of database servers and the query chaining to improve readability of connection code and simplify SQL coding.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Joomla can use different kinds of SQL database systems and run in a variety of environments with different table-prefixes. In addition to these functions, the class automatically creates the database connection. Besides instantiating the object you need just two lines of code to get a result from the database in a variety of formats. Using the Joomla database layer ensures a maximum of compatibility and flexibility for your extension.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==The Query== &amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Joomla&#039;s database querying changed with the introduction of Joomla 1.6. The recommended way of building database queries is through &#039;&#039;query chaining&#039;&#039; (although string queries are still supported).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
Query chaining refers to a method of connecting a number of methods, one after the other, with each method returning an object that can support the next method, improving readability and simplifying code.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
To obtain a new instance of the JDatabaseQuery class we use the JDatabaseDriver getQuery method:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$db = JFactory::getDbo();&lt;br /&gt;
&lt;br /&gt;
$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
The JDatabaseDriver::getQuery takes an optional argument, $new, which can be true or false (the default being false).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
To query our data source we can call a number of JDatabaseQuery methods; these methods encapsulate the data source&#039;s query language (in most cases SQL), hiding query-specific syntax from the developer and increasing the portability of the developer&#039;s source code.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
Some of the more frequently used methods include; select, from, join, where and order. There are also methods such as insert, update and delete for modifying records in the data store. By chaining these and other method calls, you can create almost any query against your data store without compromising portability of your code&amp;lt;/translate&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Selecting Records from a Single Table== &amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
Below is an example of creating a database query using the &#039;&#039;JDatabaseQuery&#039;&#039; class. Using the select, from, where and order methods, we can create queries which are flexible, easily readable and portable:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Get a db connection.&lt;br /&gt;
$db = JFactory::getDbo();&lt;br /&gt;
&lt;br /&gt;
// Create a new query object.&lt;br /&gt;
$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
// Select all records from the user profile table where key begins with &amp;quot;custom.&amp;quot;.&lt;br /&gt;
// Order it by the ordering field.&lt;br /&gt;
$query-&amp;gt;select($db-&amp;gt;quoteName(array(&#039;user_id&#039;, &#039;profile_key&#039;, &#039;profile_value&#039;, &#039;ordering&#039;)));&lt;br /&gt;
$query-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__user_profiles&#039;));&lt;br /&gt;
$query-&amp;gt;where($db-&amp;gt;quoteName(&#039;profile_key&#039;) . &#039; LIKE &#039; . $db-&amp;gt;quote(&#039;custom.%&#039;));&lt;br /&gt;
$query-&amp;gt;order(&#039;ordering ASC&#039;);&lt;br /&gt;
&lt;br /&gt;
// Reset the query using our newly populated query object.&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
// Load the results as a list of stdClass objects (see later for more options on retrieving data).&lt;br /&gt;
$results = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(Here the &#039;&#039;quoteName()&#039;&#039; function adds appropriate quotes around the column names to avoid conflicts with any database reserved word, now or in the future.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
The query can also be chained to simplify further:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query&lt;br /&gt;
    -&amp;gt;select($db-&amp;gt;quoteName(array(&#039;user_id&#039;, &#039;profile_key&#039;, &#039;profile_value&#039;, &#039;ordering&#039;)))&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__user_profiles&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;profile_key&#039;) . &#039; LIKE &#039; . $db-&amp;gt;quote(&#039;custom.%&#039;))&lt;br /&gt;
    -&amp;gt;order(&#039;ordering ASC&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
Chaining method calls improves code readability and reduces code bloat as queries become longer and more complex.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
Grouping can be achieved simply too.  The following query would count the number of articles in each category.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query&lt;br /&gt;
    -&amp;gt;select(array(&#039;catid&#039;, &#039;COUNT(*)&#039;))&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;))&lt;br /&gt;
    -&amp;gt;group($db-&amp;gt;quoteName(&#039;catid&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
A limit can be set to a query using &#039;&#039;setLimit&#039;&#039;. For example in the following query, it would return up to 10 records.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query&lt;br /&gt;
    -&amp;gt;select($db-&amp;gt;quoteName(array(&#039;user_id&#039;, &#039;profile_key&#039;, &#039;profile_value&#039;, &#039;ordering&#039;)))&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__user_profiles&#039;))&lt;br /&gt;
    -&amp;gt;setLimit(&#039;10&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Selecting Records from Multiple Tables== &amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
Using the JDatabaseQuery&#039;s [https://api.joomla.org/cms-3/classes/JDatabaseQuery.html#method_join join] methods, we can select records from multiple related tables. The generic &#039;&#039;join&#039;&#039; method takes two arguments; the join &#039;&#039;type&#039;&#039; (inner, outer, left, right) and the join condition. In the following example you will notice that we can use all of the keywords we would normally use if we were writing a native SQL query, including the AS keyword for aliasing tables and the ON keyword for creating relationships between tables. Also note that the table alias is used in all methods which reference table columns (I.e. select, where, order).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Get a db connection.&lt;br /&gt;
$db = JFactory::getDbo();&lt;br /&gt;
&lt;br /&gt;
// Create a new query object.&lt;br /&gt;
$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
// Select all articles for users who have a username which starts with &#039;a&#039;.&lt;br /&gt;
// Order it by the created date.&lt;br /&gt;
// Note by putting &#039;a&#039; as a second parameter will generate `#__content` AS `a`&lt;br /&gt;
$query&lt;br /&gt;
    -&amp;gt;select(array(&#039;a.*&#039;, &#039;b.username&#039;, &#039;b.name&#039;))&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;))&lt;br /&gt;
    -&amp;gt;join(&#039;INNER&#039;, $db-&amp;gt;quoteName(&#039;#__users&#039;, &#039;b&#039;) . &#039; ON &#039; . $db-&amp;gt;quoteName(&#039;a.created_by&#039;) . &#039; = &#039; . $db-&amp;gt;quoteName(&#039;b.id&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;b.username&#039;) . &#039; LIKE &#039; . $db-&amp;gt;quote(&#039;a%&#039;))&lt;br /&gt;
    -&amp;gt;order($db-&amp;gt;quoteName(&#039;a.created&#039;) . &#039; DESC&#039;);&lt;br /&gt;
&lt;br /&gt;
// Reset the query using our newly populated query object.&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
// Load the results as a list of stdClass objects (see later for more options on retrieving data).&lt;br /&gt;
$results = $db-&amp;gt;loadObjectList();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
The join method above enables us to query both the content and user tables, retrieving articles with their author details. There are also convenience methods for joins:&amp;lt;/translate&amp;gt;&lt;br /&gt;
* [https://api.joomla.org/cms-3/classes/JDatabaseQuery.html#method_innerJoin innerJoin()]&lt;br /&gt;
* [https://api.joomla.org/cms-3/classes/JDatabaseQuery.html#method_leftJoin leftJoin()]&lt;br /&gt;
* [https://api.joomla.org/cms-3/classes/JDatabaseQuery.html#method_rightJoin rightJoin()]&lt;br /&gt;
* [https://api.joomla.org/cms-3/classes/JDatabaseQuery.html#method_outerJoin outerJoin()]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
We can use multiple joins to query across more than two tables:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query&lt;br /&gt;
    -&amp;gt;select(array(&#039;a.*&#039;, &#039;b.username&#039;, &#039;b.name&#039;, &#039;c.*&#039;, &#039;d.*&#039;))&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;))&lt;br /&gt;
    -&amp;gt;join(&#039;INNER&#039;, $db-&amp;gt;quoteName(&#039;#__users&#039;, &#039;b&#039;) . &#039; ON &#039; . $db-&amp;gt;quoteName(&#039;a.created_by&#039;) . &#039; = &#039; . $db-&amp;gt;quoteName(&#039;b.id&#039;))&lt;br /&gt;
    -&amp;gt;join(&#039;LEFT&#039;, $db-&amp;gt;quoteName(&#039;#__user_profiles&#039;, &#039;c&#039;) . &#039; ON &#039; . $db-&amp;gt;quoteName(&#039;b.id&#039;) . &#039; = &#039; . $db-&amp;gt;quoteName(&#039;c.user_id&#039;))&lt;br /&gt;
    -&amp;gt;join(&#039;RIGHT&#039;, $db-&amp;gt;quoteName(&#039;#__categories&#039;, &#039;d&#039;) . &#039; ON &#039; . $db-&amp;gt;quoteName(&#039;a.catid&#039;) . &#039; = &#039; . $db-&amp;gt;quoteName(&#039;d.id&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;b.username&#039;) . &#039; LIKE &#039; . $db-&amp;gt;quote(&#039;a%&#039;))&lt;br /&gt;
    -&amp;gt;order($db-&amp;gt;quoteName(&#039;a.created&#039;) . &#039; DESC&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
Notice how chaining makes the source code much more readable for these longer queries.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
In some cases, you will also need to use the AS clause when selecting items to avoid column name conflicts. In this case, multiple select statements can be chained in conjunction with using the second parameter of $db-&amp;gt;quoteName.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query&lt;br /&gt;
    -&amp;gt;select(&#039;a.*&#039;)&lt;br /&gt;
    -&amp;gt;select($db-&amp;gt;quoteName(&#039;b.username&#039;, &#039;username&#039;))&lt;br /&gt;
    -&amp;gt;select($db-&amp;gt;quoteName(&#039;b.name&#039;, &#039;name&#039;))&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;))&lt;br /&gt;
    -&amp;gt;join(&#039;INNER&#039;, $db-&amp;gt;quoteName(&#039;#__users&#039;, &#039;b&#039;) . &#039; ON &#039; . $db-&amp;gt;quoteName(&#039;a.created_by&#039;) . &#039; = &#039; . $db-&amp;gt;quoteName(&#039;b.id&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;b.username&#039;) . &#039; LIKE &#039; . $db-&amp;gt;quote(&#039;a%&#039;))&lt;br /&gt;
    -&amp;gt;order($db-&amp;gt;quoteName(&#039;a.created&#039;) . &#039; DESC&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
A second array can also be used as the second parameter of the select statement to populate the values of the AS clause. Remember to include nulls in the second array to correspond to columns in the first array that you don&#039;t want to use the AS clause for:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query&lt;br /&gt;
    -&amp;gt;select(array(&#039;a.*&#039;))&lt;br /&gt;
    -&amp;gt;select($db-&amp;gt;quoteName(array(&#039;b.username&#039;, &#039;b.name&#039;), array(&#039;username&#039;, &#039;name&#039;)))&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__content&#039;, &#039;a&#039;))&lt;br /&gt;
    -&amp;gt;join(&#039;INNER&#039;, $db-&amp;gt;quoteName(&#039;#__users&#039;, &#039;b&#039;) . &#039; ON &#039; . $db-&amp;gt;quoteName(&#039;a.created_by&#039;) . &#039; = &#039; . $db-&amp;gt;quoteName(&#039;b.id&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;b.username&#039;) . &#039; LIKE &#039; . $db-&amp;gt;quote(&#039;a%&#039;))&lt;br /&gt;
    -&amp;gt;order($db-&amp;gt;quoteName(&#039;a.created&#039;) . &#039; DESC&#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Using OR in queries== &amp;lt;!--T:140--&amp;gt; &amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:141--&amp;gt;&lt;br /&gt;
When using multiple WHERE clauses in your query, they will be treated as an AND.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:142--&amp;gt;&lt;br /&gt;
So, for example, the query below will return results where the &#039;name&#039; field AND the &#039;state&#039; field match.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query = $db&lt;br /&gt;
    -&amp;gt;getQuery(true)&lt;br /&gt;
    -&amp;gt;select(&#039;COUNT(*)&#039;)&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__my_table&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;name&#039;) . &amp;quot; = &amp;quot; . $db-&amp;gt;quote($value)&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;state&#039;) . &amp;quot; = &amp;quot; . $db-&amp;gt;quote($state));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:143--&amp;gt;&lt;br /&gt;
To use a WHERE clause as an OR, the query can be written like this&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query = $db&lt;br /&gt;
    -&amp;gt;getQuery(true)&lt;br /&gt;
    -&amp;gt;select(&#039;COUNT(*)&#039;)&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__my_table&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;name&#039;) . &amp;quot; = &amp;quot; . $db-&amp;gt;quote($name_one), &#039;OR&#039;)&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;name&#039;) . &amp;quot; = &amp;quot; . $db-&amp;gt;quote($name_two));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:144--&amp;gt;&lt;br /&gt;
it can also be written like this&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$query = $db&lt;br /&gt;
    -&amp;gt;getQuery(true)&lt;br /&gt;
    -&amp;gt;select(&#039;COUNT(*)&#039;)&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__my_table&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;name&#039;) . &amp;quot; = &amp;quot; . $db-&amp;gt;quote($name_one)&lt;br /&gt;
    -&amp;gt;orWhere($db-&amp;gt;quoteName(&#039;name&#039;) . &amp;quot; = &amp;quot; . $db-&amp;gt;quote($name_two));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Query Results == &amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
The database class contains many methods for working with a query&#039;s result set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:145--&amp;gt;&lt;br /&gt;
If there are no matches to the query, the result will be null.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== Single Value Result === &amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== loadResult() ==== &amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
Use &#039;&#039;&#039;loadResult()&#039;&#039;&#039; when you expect just a single value back from your database query.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;translate&amp;gt;&amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
id&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
name&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
email&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
username&amp;lt;/translate&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 1 || style=&amp;quot;background:yellow&amp;quot; | John Smith || &amp;lt;translate&amp;gt;&amp;lt;!--T:39--&amp;gt;&lt;br /&gt;
johnsmith@domain.example&amp;lt;/translate&amp;gt; || johnsmith&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Magda Hellman || &amp;lt;translate&amp;gt;&amp;lt;!--T:40--&amp;gt;&lt;br /&gt;
magda_h@domain.example&amp;lt;/translate&amp;gt; || magdah&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Yvonne de Gaulle || &amp;lt;translate&amp;gt;&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
ydg@domain.example&amp;lt;/translate&amp;gt; || ydegaulle&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
This is often the result of a &#039;count&#039; query to get a number of records:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$db = JFactory::getDbo();&lt;br /&gt;
$query = $db&lt;br /&gt;
    -&amp;gt;getQuery(true)&lt;br /&gt;
    -&amp;gt;select(&#039;COUNT(*)&#039;)&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__my_table&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;name&#039;) . &amp;quot; = &amp;quot; . $db-&amp;gt;quote($value));&lt;br /&gt;
&lt;br /&gt;
// Reset the query using our newly populated query object.&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$count = $db-&amp;gt;loadResult();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:134--&amp;gt;&lt;br /&gt;
or where you are just looking for a single field from a single row of the table (or possibly a single field from the first row returned).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
$db = JFactory::getDbo();&lt;br /&gt;
$query = $db&lt;br /&gt;
    -&amp;gt;getQuery(true)&lt;br /&gt;
    -&amp;gt;select(&#039;field_name&#039;)&lt;br /&gt;
    -&amp;gt;from($db-&amp;gt;quoteName(&#039;#__my_table&#039;))&lt;br /&gt;
    -&amp;gt;where($db-&amp;gt;quoteName(&#039;some_name&#039;) . &amp;quot; = &amp;quot; . $db-&amp;gt;quote($some_value));&lt;br /&gt;
&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$result = $db-&amp;gt;loadResult();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
===Single Row Results === &amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:44--&amp;gt;&lt;br /&gt;
Each of these results functions will return a single record from the database even though there may be several records that meet the criteria that you have set. To get more records you need to call the function again.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;translate&amp;gt;&amp;lt;!--T:45--&amp;gt;&lt;br /&gt;
id&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
name&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
email&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
username&amp;lt;/translate&amp;gt;&lt;br /&gt;
|- style=&amp;quot;background:yellow&amp;quot;&lt;br /&gt;
| 1 || John Smith || &amp;lt;translate&amp;gt;&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
johnsmith@domain.example&amp;lt;/translate&amp;gt; || johnsmith&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Magda Hellman || &amp;lt;translate&amp;gt;&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
magda_h@domain.example&amp;lt;/translate&amp;gt; || magdah&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Yvonne de Gaulle || &amp;lt;translate&amp;gt;&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
ydg@domain.example&amp;lt;/translate&amp;gt; || ydegaulle&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== loadRow() ==== &amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
&#039;&#039;loadRow()&#039;&#039; returns an indexed array from a single record in the table:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadRow();&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:133--&amp;gt;&lt;br /&gt;
will give:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [0] =&amp;gt; 1, [1] =&amp;gt; John Smith, [2] =&amp;gt; johnsmith@domain.example, [3] =&amp;gt; johnsmith ) &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:54--&amp;gt;&lt;br /&gt;
You can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;index&#039;] // e.g. $row[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
Notes:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
# The array indices are numeric starting from zero.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
# Whilst you can repeat the call to get further rows, one of the functions that returns multiple rows might be more useful.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== loadAssoc() ==== &amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
&#039;&#039;loadAssoc()&#039;&#039; returns an associated array from a single record in the table:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadAssoc();&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
will give:&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [id] =&amp;gt; 1, [name] =&amp;gt; John Smith, [email] =&amp;gt; johnsmith@domain.example, [username] =&amp;gt; johnsmith )&amp;lt;/pre&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
You can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;name&#039;] // e.g. $row[&#039;email&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
Notes:&lt;br /&gt;
# Whilst you can repeat the call to get further rows, one of the functions that returns multiple rows might be more useful.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== loadObject() ==== &amp;lt;!--T:63--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:64--&amp;gt;&lt;br /&gt;
loadObject returns a PHP object from a single record in the table:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$result = $db-&amp;gt;loadObject();&lt;br /&gt;
print_r($result);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:65--&amp;gt;&lt;br /&gt;
will give:&lt;br /&gt;
&amp;lt;pre&amp;gt;stdClass Object ( [id] =&amp;gt; 1, [name] =&amp;gt; John Smith, [email] =&amp;gt; johnsmith@domain.example, [username] =&amp;gt; johnsmith )&amp;lt;/pre&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:66--&amp;gt;&lt;br /&gt;
You can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$result-&amp;gt;index // e.g. $result-&amp;gt;email&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:67--&amp;gt;&lt;br /&gt;
Notes:&lt;br /&gt;
# Whilst you can repeat the call to get further rows, one of the functions that returns multiple rows might be more useful.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
===Single Column Results === &amp;lt;!--T:68--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:69--&amp;gt;&lt;br /&gt;
Each of these results functions will return a single column from the database.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;translate&amp;gt;&amp;lt;!--T:70--&amp;gt;&lt;br /&gt;
id&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:71--&amp;gt;&lt;br /&gt;
name&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:72--&amp;gt;&lt;br /&gt;
email&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:73--&amp;gt;&lt;br /&gt;
username&amp;lt;/translate&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| 1 || style=&amp;quot;background:yellow&amp;quot; | John Smith || &amp;lt;translate&amp;gt;&amp;lt;!--T:74--&amp;gt;&lt;br /&gt;
johnsmith@domain.example&amp;lt;/translate&amp;gt; || johnsmith&lt;br /&gt;
|-&lt;br /&gt;
| 2 || style=&amp;quot;background:yellow&amp;quot; | Magda Hellman || &amp;lt;translate&amp;gt;&amp;lt;!--T:75--&amp;gt;&lt;br /&gt;
magda_h@domain.example&amp;lt;/translate&amp;gt; || magdah&lt;br /&gt;
|-&lt;br /&gt;
| 3 || style=&amp;quot;background:yellow&amp;quot; | Yvonne de Gaulle || &amp;lt;translate&amp;gt;&amp;lt;!--T:76--&amp;gt;&lt;br /&gt;
ydg@domain.example&amp;lt;/translate&amp;gt; || ydegaulle&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== loadColumn() ==== &amp;lt;!--T:77--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:78--&amp;gt;&lt;br /&gt;
&#039;&#039;loadColumn()&#039;&#039; returns an indexed array from a single column in the table:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
$query-&amp;gt;select(&#039;name&#039;));&lt;br /&gt;
      -&amp;gt;from . . .&amp;quot;;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$column= $db-&amp;gt;loadColumn();&lt;br /&gt;
print_r($column);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:79--&amp;gt;&lt;br /&gt;
will give:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [0] =&amp;gt; John Smith, [1] =&amp;gt; Magda Hellman, [2] =&amp;gt; Yvonne de Gaulle )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:80--&amp;gt;&lt;br /&gt;
You can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$column[&#039;index&#039;] // e.g. $column[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:81--&amp;gt;&lt;br /&gt;
Notes:&lt;br /&gt;
# The array indices are numeric starting from zero.&lt;br /&gt;
# &#039;&#039;loadColumn()&#039;&#039; is equivalent to loadColumn(0).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== loadColumn($index) ==== &amp;lt;!--T:82--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:83--&amp;gt;&lt;br /&gt;
loadColumn($index) returns an indexed array from a single column in the table:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
$query-&amp;gt;select(array(&#039;name&#039;, &#039;email&#039;, &#039;username&#039;));&lt;br /&gt;
      -&amp;gt;from . . .&amp;quot;;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$column= $db-&amp;gt;loadColumn(1);&lt;br /&gt;
print_r($column);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:84--&amp;gt;&lt;br /&gt;
will give:&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [0] =&amp;gt; johnsmith@domain.example, [1] =&amp;gt; magda_h@domain.example, [2] =&amp;gt; ydg@domain.example )&amp;lt;/pre&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:85--&amp;gt;&lt;br /&gt;
You can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$column[&#039;index&#039;] // e.g. $column[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:86--&amp;gt;&lt;br /&gt;
loadColumn($index) allows you to iterate through a series of columns in the results&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
for ( $i = 0; $i &amp;lt;= 2; $i++ ) {&lt;br /&gt;
  $column= $db-&amp;gt;loadColumn($i);&lt;br /&gt;
  print_r($column);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:87--&amp;gt;&lt;br /&gt;
will give:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;Array ( [0] =&amp;gt; John Smith, [1] =&amp;gt; Magda Hellman, [2] =&amp;gt; Yvonne de Gaulle ),&lt;br /&gt;
Array ( [0] =&amp;gt; johnsmith@domain.example, [1] =&amp;gt; magda_h@domain.example, [2] =&amp;gt; ydg@domain.example ),&lt;br /&gt;
Array ( [0] =&amp;gt; johnsmith, [1] =&amp;gt; magdah, [2] =&amp;gt; ydegaulle )&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:88--&amp;gt;&lt;br /&gt;
Notes:&lt;br /&gt;
# The array indices are numeric starting from zero.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== Multi-Row Results === &amp;lt;!--T:89--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:90--&amp;gt;&lt;br /&gt;
Each of these results functions will return multiple records from the database.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! &amp;lt;translate&amp;gt;&amp;lt;!--T:91--&amp;gt;&lt;br /&gt;
id&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:92--&amp;gt;&lt;br /&gt;
name&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:93--&amp;gt;&lt;br /&gt;
email&amp;lt;/translate&amp;gt; !! &amp;lt;translate&amp;gt;&amp;lt;!--T:94--&amp;gt;&lt;br /&gt;
username&amp;lt;/translate&amp;gt;&lt;br /&gt;
|- style=&amp;quot;background:yellow&amp;quot;&lt;br /&gt;
| 1 || John Smith || johnsmith@domain.example || johnsmith&lt;br /&gt;
|- style=&amp;quot;background:yellow&amp;quot;&lt;br /&gt;
| 2 || Magda Hellman || magda_h@domain.example || magdah&lt;br /&gt;
|- style=&amp;quot;background:yellow&amp;quot;&lt;br /&gt;
| 3 || Yvonne de Gaulle || ydg@domain.example || ydegaulle&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== loadRowList() ==== &amp;lt;!--T:95--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:96--&amp;gt;&lt;br /&gt;
&#039;&#039;loadRowList()&#039;&#039; returns an indexed array of indexed arrays from the table records returned by the query:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadRowList();&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:97--&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Array (&lt;br /&gt;
[0] =&amp;gt; Array ( [0] =&amp;gt; 1, [1] =&amp;gt; John Smith, [2] =&amp;gt; johnsmith@domain.example, [3] =&amp;gt; johnsmith ),&lt;br /&gt;
[1] =&amp;gt; Array ( [0] =&amp;gt; 2, [1] =&amp;gt; Magda Hellman, [2] =&amp;gt; magda_h@domain.example, [3] =&amp;gt; magdah ),&lt;br /&gt;
[2] =&amp;gt; Array ( [0] =&amp;gt; 3, [1] =&amp;gt; Yvonne de Gaulle, [2] =&amp;gt; ydg@domain.example, [3] =&amp;gt; ydegaulle )&lt;br /&gt;
)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:98--&amp;gt;&lt;br /&gt;
You can access the individual rows by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;index&#039;] // e.g. $row[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:99--&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;index&#039;][&#039;index&#039;] // e.g. $row[&#039;2&#039;][&#039;3&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:100--&amp;gt;&lt;br /&gt;
Notes:&lt;br /&gt;
# The array indices are numeric starting from zero.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;==== loadAssocList() ==== &amp;lt;!--T:101--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:102--&amp;gt;&lt;br /&gt;
&#039;&#039;loadAssocList()&#039;&#039; returns an indexed array of associated arrays from the table records returned by the query:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadAssocList();&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:103--&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;Array (&lt;br /&gt;
[0] =&amp;gt; Array ( [id] =&amp;gt; 1, [name] =&amp;gt; John Smith, [email] =&amp;gt; johnsmith@domain.example, [username] =&amp;gt; johnsmith ),&lt;br /&gt;
[1] =&amp;gt; Array ( [id] =&amp;gt; 2, [name] =&amp;gt; Magda Hellman, [email] =&amp;gt; magda_h@domain.example, [username] =&amp;gt; magdah ),&lt;br /&gt;
[2] =&amp;gt; Array ( [id] =&amp;gt; 3, [name] =&amp;gt; Yvonne de Gaulle, [email] =&amp;gt; ydg@domain.example, [username] =&amp;gt; ydegaulle )&lt;br /&gt;
) &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:104--&amp;gt;&lt;br /&gt;
You can access the individual rows by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;index&#039;] // e.g. $row[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:105--&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;index&#039;][&#039;column_name&#039;] // e.g. $row[&#039;2&#039;][&#039;email&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;==== loadAssocList($key) ==== &amp;lt;!--T:106--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:107--&amp;gt;&lt;br /&gt;
&#039;&#039;loadAssocList(&#039;key&#039;)&#039;&#039; returns an associated array - indexed on &#039;key&#039; - of associated arrays from the table records returned by the query:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadAssocList(&#039;username&#039;);&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:108--&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;Array (&lt;br /&gt;
[johnsmith] =&amp;gt; Array ( [id] =&amp;gt; 1, [name] =&amp;gt; John Smith, [email] =&amp;gt; johnsmith@domain.example, [username] =&amp;gt; johnsmith ),&lt;br /&gt;
[magdah] =&amp;gt; Array ( [id] =&amp;gt; 2, [name] =&amp;gt; Magda Hellman, [email] =&amp;gt; magda_h@domain.example, [username] =&amp;gt; magdah ),&lt;br /&gt;
[ydegaulle] =&amp;gt; Array ( [id] =&amp;gt; 3, [name] =&amp;gt; Yvonne de Gaulle, [email] =&amp;gt; ydg@domain.example, [username] =&amp;gt; ydegaulle )&lt;br /&gt;
)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:109--&amp;gt;&lt;br /&gt;
You can access the individual rows by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;key_value&#039;] // e.g. $row[&#039;johnsmith&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:110--&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;key_value&#039;][&#039;column_name&#039;] // e.g. $row[&#039;johnsmith&#039;][&#039;email&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:111--&amp;gt;&lt;br /&gt;
Note: Key must be a valid column name from the table; it does not have to be an Index or a Primary Key. But if it does not have a unique value you may not be able to retrieve results reliably.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;==== loadAssocList($key, $column) ==== &amp;lt;!--T:112--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:113--&amp;gt;&lt;br /&gt;
&#039;&#039;loadAssocList(&#039;key&#039;, &#039;column&#039;)&#039;&#039; returns an associative array, indexed on &#039;key&#039;, of values from the column named &#039;column&#039; returned by the query:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadAssocList(&#039;id&#039;, &#039;username&#039;);&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:114--&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;Array (&lt;br /&gt;
[1] =&amp;gt; John Smith,&lt;br /&gt;
[2] =&amp;gt; Magda Hellman,&lt;br /&gt;
[3] =&amp;gt; Yvonne de Gaulle,&lt;br /&gt;
)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:115--&amp;gt;&lt;br /&gt;
Note: Key must be a valid column name from the table; it does not have to be an Index or a Primary Key. But if it does not have a unique value you may not be able to retrieve results reliably.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;==== loadObjectList() ==== &amp;lt;!--T:116--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:117--&amp;gt;&lt;br /&gt;
&#039;&#039;loadObjectList()&#039;&#039; returns an indexed array of PHP objects from the table records returned by the query:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadObjectList();&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:118--&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;Array (&lt;br /&gt;
[0] =&amp;gt; stdClass Object ( [id] =&amp;gt; 1, [name] =&amp;gt; John Smith,&lt;br /&gt;
    [email] =&amp;gt; johnsmith@domain.example, [username] =&amp;gt; johnsmith ),&lt;br /&gt;
[1] =&amp;gt; stdClass Object ( [id] =&amp;gt; 2, [name] =&amp;gt; Magda Hellman,&lt;br /&gt;
    [email] =&amp;gt; magda_h@domain.example, [username] =&amp;gt; magdah ),&lt;br /&gt;
[2] =&amp;gt; stdClass Object ( [id] =&amp;gt; 3, [name] =&amp;gt; Yvonne de Gaulle,&lt;br /&gt;
    [email] =&amp;gt; ydg@domain.example, [username] =&amp;gt; ydegaulle )&lt;br /&gt;
)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:119--&amp;gt;&lt;br /&gt;
You can access the individual rows by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;index&#039;] // e.g. $row[&#039;2&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:120--&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;index&#039;]-&amp;gt;name // e.g. $row[&#039;2&#039;]-&amp;gt;email&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;==== loadObjectList($key) ==== &amp;lt;!--T:121--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:122--&amp;gt;&lt;br /&gt;
&#039;&#039;loadObjectList(&#039;key&#039;)&#039;&#039; returns an associated array - indexed on &#039;key&#039; - of objects from the table records returned by the query:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$row = $db-&amp;gt;loadObjectList(&#039;username&#039;);&lt;br /&gt;
print_r($row);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:123--&amp;gt;&lt;br /&gt;
will give (with line breaks added for clarity):&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;Array (&lt;br /&gt;
[johnsmith] =&amp;gt; stdClass Object ( [id] =&amp;gt; 1, [name] =&amp;gt; John Smith,&lt;br /&gt;
    [email] =&amp;gt; johnsmith@domain.example, [username] =&amp;gt; johnsmith ),&lt;br /&gt;
[magdah] =&amp;gt; stdClass Object ( [id] =&amp;gt; 2, [name] =&amp;gt; Magda Hellman,&lt;br /&gt;
    [email] =&amp;gt; magda_h@domain.example, [username] =&amp;gt; magdah ),&lt;br /&gt;
[ydegaulle] =&amp;gt; stdClass Object ( [id] =&amp;gt; 3, [name] =&amp;gt; Yvonne de Gaulle,&lt;br /&gt;
    [email] =&amp;gt; ydg@domain.example, [username] =&amp;gt; ydegaulle )&lt;br /&gt;
)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:124--&amp;gt;&lt;br /&gt;
You can access the individual rows by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;key_value&#039;] // e.g. $row[&#039;johnsmith&#039;]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:125--&amp;gt;&lt;br /&gt;
and you can access the individual values by using:&amp;lt;/translate&amp;gt;&amp;lt;pre&amp;gt;$row[&#039;key_value&#039;]-&amp;gt;column_name // e.g. $row[&#039;johnsmith&#039;]-&amp;gt;email&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:126--&amp;gt;&lt;br /&gt;
Note: Key must be a valid column name from the table; it does not have to be an Index or a Primary Key. But if it does not have a unique value you may not be able to retrieve results reliably.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== Miscellaneous Result Set Methods === &amp;lt;!--T:127--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==== getNumRows() ==== &amp;lt;!--T:128--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:129--&amp;gt;&lt;br /&gt;
&#039;&#039;getNumRows()&#039;&#039; will return the number of result rows found by the last SELECT or SHOW query and waiting to be read. To get a result from getNumRows() you have to run it &#039;&#039;&#039;after&#039;&#039;&#039; the query and &#039;&#039;&#039;before&#039;&#039;&#039; you have retrieved any results. To retrieve the number of rows affected by a INSERT, UPDATE, REPLACE or DELETE query, use getAffectedRows().&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&#039;php&#039;&amp;gt;&lt;br /&gt;
. . .&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
$db-&amp;gt;execute();&lt;br /&gt;
$num_rows = $db-&amp;gt;getNumRows();&lt;br /&gt;
print_r($num_rows);&lt;br /&gt;
$result = $db-&amp;gt;loadRowList();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:130--&amp;gt;&lt;br /&gt;
will return&amp;lt;/translate&amp;gt; &amp;lt;pre&amp;gt;3&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:131--&amp;gt;&lt;br /&gt;
Note: getNumRows() is only valid for statements like SELECT or SHOW that return an actual result set. If you run getNumRows() after loadRowList() - or any other retrieval method - you will get a PHP Warning:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;Warning: mysql_num_rows(): 80 is not a valid MySQL result resource&lt;br /&gt;
in libraries\joomla\database\database\mysql.php on line 344&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample Module Code ==&lt;br /&gt;
Below is the code for a simple Joomla module which you can install and run to demonstrate use of the JDatabase functionality, and which you can adapt to experiment with some of the concepts described above. If you are unsure about development and installing a Joomla module then following the tutorial at [[S:MyLanguage/J3.x:Creating a simple module/Introduction| Creating a simple module ]] will help.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039; In any Joomla extensions that you develop avoid accessing the core Joomla tables directly like this. Instead use the Joomla APIs. The database structures may change without warning.&lt;br /&gt;
&lt;br /&gt;
In a folder mod_db_select create the following 2 files:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;mod_db_select.xml&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.1&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;Database select query demo&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.1&amp;lt;/version&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Code demonstrating use of Joomla Database class to perform SQL SELECT queries&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_db_select&amp;quot;&amp;gt;mod_db_select.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;mod_db_select.php&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted Access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
$db = Factory::getDbo();&lt;br /&gt;
&lt;br /&gt;
$me = Factory::getUser();&lt;br /&gt;
&lt;br /&gt;
$query = $db-&amp;gt;getQuery(true);&lt;br /&gt;
&lt;br /&gt;
$query-&amp;gt;select($db-&amp;gt;quoteName(array(&#039;name&#039;, &#039;email&#039;)))&lt;br /&gt;
	-&amp;gt;from($db-&amp;gt;quoteName(&#039;#__users&#039;))&lt;br /&gt;
	-&amp;gt;where($db-&amp;gt;quoteName(&#039;id&#039;) . &#039; != &#039; . $db-&amp;gt;quote($me-&amp;gt;id))&lt;br /&gt;
	-&amp;gt;order($db-&amp;gt;quoteName(&#039;name&#039;) . &#039; ASC&#039;);&lt;br /&gt;
&lt;br /&gt;
$db-&amp;gt;setQuery($query);&lt;br /&gt;
&lt;br /&gt;
echo $db-&amp;gt;replacePrefix((string) $query);&lt;br /&gt;
&lt;br /&gt;
$results = $db-&amp;gt;loadAssocList();&lt;br /&gt;
&lt;br /&gt;
foreach ($results as $row) {&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;&amp;quot; . $row[&#039;name&#039;] . &amp;quot;, &amp;quot; . $row[&#039;email&#039;] . &amp;quot;&amp;lt;br&amp;gt;&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The code above selects and outputs the username and email of the records in the Joomla &#039;&#039;users&#039;&#039; table, apart from those of the currently logged-on user. The method &#039;&#039;Factory::getUser()&#039;&#039; returns the &#039;&#039;user&#039;&#039; object of the currently logged-on user, or if not logged on, then a blank &#039;&#039;user&#039;&#039; object, whose &#039;&#039;id&#039;&#039; field is set to zero.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;$db-&amp;gt;replacePrefix((string) $query)&#039;&#039; expression returns the actual SQL statement, and outputting this can be useful in debugging.&lt;br /&gt;
&lt;br /&gt;
Zip up the mod_db_select directory to create &#039;&#039;mod_db_select.zip&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Within your Joomla Administrator, go to Install Extensions and via the Upload Package File tab select this zip file to install this sample log module.&lt;br /&gt;
&lt;br /&gt;
Make this module visible by editing it (click on it within the Modules page). Then:&lt;br /&gt;
# Make its status &#039;&#039;Published&#039;&#039;&lt;br /&gt;
# Select a position on the page for it to be shown&lt;br /&gt;
# Specify the pages it should appear on in the menu assignment tab&lt;br /&gt;
&lt;br /&gt;
When you visit a site web page, you should see the module in your selected position. It should output the SQL SELECT statement and the sequence of name, email values from the Joomla users table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== See also == &amp;lt;!--T:135--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
*[[S:MyLanguage/Inserting, Updating and Removing data using JDatabase|&amp;lt;translate&amp;gt;&amp;lt;!--T:136--&amp;gt; Inserting, Updating and Removing data using JDatabase&amp;lt;/translate&amp;gt;]]&lt;br /&gt;
*[[S:MyLanguage/Using the union methods in database queries|&amp;lt;translate&amp;gt;&amp;lt;!--T:137--&amp;gt; Using the union methods in database queries&amp;lt;/translate&amp;gt;]] &amp;lt;translate&amp;gt;&amp;lt;!--T:138--&amp;gt; (Joomla! 3.3+)&amp;lt;/translate&amp;gt;&lt;br /&gt;
*[https://api.joomla.org/cms-3/classes/JDatabaseQuery.html &amp;lt;translate&amp;gt;&amp;lt;!--T:139--&amp;gt; Joomla CMS 3.8 API&amp;lt;/translate&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Database{{#translation:}}]]&lt;br /&gt;
[[Category:JFactory{{#translation:}}]]&lt;br /&gt;
[[Category:Extension development{{#translation:}}]]&lt;br /&gt;
[[Category:Development Recommended Reading{{#translation:}}]]&lt;br /&gt;
[[Category:Tutorials{{#translation:}}]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J3.x:Adding_JavaScript_and_CSS_to_the_page&amp;diff=1033484</id>
		<title>J3.x:Adding JavaScript and CSS to the page</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J3.x:Adding_JavaScript_and_CSS_to_the_page&amp;diff=1033484"/>
		<updated>2024-11-27T10:34:13Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/javascript/adding-javascript/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:52--&amp;gt;&lt;br /&gt;
This is one of a series of [[API Guides]], which aim to help you understand how to use the Joomla APIs through providing detailed explanations and sample code which you can easily install and run.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Inserting from a File == &amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:53--&amp;gt;&lt;br /&gt;
Joomla allows you to add JavaScript and CSS files to your HTML document, and it puts the associated &#039;&#039;&amp;lt;script&amp;gt;&#039;&#039; and &#039;&#039;&amp;lt;link&amp;gt;&#039;&#039; elements within the HTML &#039;&#039;&amp;lt;head&amp;gt;&#039;&#039; section. To do this you call the &#039;&#039;addScript&#039;&#039; and &#039;&#039;addStyleSheet&#039;&#039; methods of the Joomla object which represents the HTML document. Since Joomla! buffers all the HTML-related data that makes up a page before output, it is possible to call these methods anywhere within your code. &amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
First, get a reference to the current document object:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
$document = Factory::getDocument();&lt;br /&gt;
// above 2 lines are equivalent to the older form: $document = JFactory::getDocument();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Then for a style sheet, use this code:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$document-&amp;gt;addStyleSheet($url);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
To add a JavaScript file, use this code:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$document-&amp;gt;addScript($url);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
where &#039;&#039;$url&#039;&#039; is the variable containing the full path to the JavaScript or CSS file. For example:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&#039;&#039;JUri::base() . &#039;templates/custom/js/sample.js&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Note this will &#039;&#039;&#039;not&#039;&#039;&#039; include Mootools or jQuery. If your script requires Mootools or jQuery see [[S:MyLanguage/Javascript_Frameworks|JavaScript Frameworks]] for full details on how to include them. (Note that jQuery can only be included natively on Joomla! 3.0+.)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
It used to be possible to do this with JHTML, however, this was deprecated in Joomla 2.5 and removed in Joomla 3.x.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== $options and $attributes Parameters === &amp;lt;!--T:54--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:55--&amp;gt;&lt;br /&gt;
You can add &#039;&#039;$options&#039;&#039; and &#039;&#039;$attributes&#039;&#039; parameters to the above methods. The &#039;&#039;$options&#039;&#039; control overall how the &#039;&#039;&amp;lt;script&amp;gt;&#039;&#039; and &#039;&#039;&amp;lt;link&amp;gt;&#039;&#039; elements are output while the &#039;&#039;$attributes&#039;&#039; get set as HTML attributes within those tags. (Note that although there are Deprecated markers against the addScript and addStyleSheet methods of the [https://api.joomla.org/cms-3/classes/Joomla.CMS.Document.Document.html#method_addScript Joomla Document API], these markers refer just to the signature of these methods; the form of the signature using &#039;&#039;$options&#039;&#039; and &#039;&#039;$attributes&#039;&#039; parameters is not deprecated).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:56--&amp;gt;&lt;br /&gt;
The &#039;&#039;$options&#039;&#039; parameter should be an array and 2 different options are currently supported:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:57--&amp;gt;&lt;br /&gt;
* &#039;&#039;version =&amp;gt; auto&#039;&#039; If this is set then a &#039;media version&#039; is appended as a query parameter to the CSS or JavaScript URL within the &#039;&#039;&amp;lt;script&amp;gt;&#039;&#039; or &#039;&#039;&amp;lt;link&amp;gt;&#039;&#039; element. This is a string (an md5 hash) that is generated from factors including the Joomla version, your Joomla instance &#039;&#039;secret&#039;&#039; and the date/time at which the media version was generated. The media version is regenerated whenever anything is installed on the Joomla instance. Its purpose is to force browsers to reload the CSS and JavaScript files instead of using possibly outdated versions from cache.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:58--&amp;gt;&lt;br /&gt;
For example&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$document-&amp;gt;addStyleSheet(&amp;quot;...demo.css&amp;quot;, array(&#039;version&#039;=&amp;gt;&#039;auto&#039;));&lt;br /&gt;
// leads to something like&lt;br /&gt;
// &amp;lt;link href=&amp;quot;...demo.css?37e343bbb4073e0dfe5b1eb40b6&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:59--&amp;gt;&lt;br /&gt;
The string of characters after the &#039;&#039;?&#039;&#039; is the md5 hash, which will change when extensions or Joomla itself are installed/upgraded/uninstalled. &amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:60--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;conditional&#039; =&amp;gt; &#039;lt IE 9&#039;&#039;&#039; (as an example). This outputs the &#039;&#039;&amp;lt;script&amp;gt;&#039;&#039; or &#039;&#039;&amp;lt;link&amp;gt;&#039;&#039; within a [https://en.wikipedia.org/wiki/Conditional_comment Conditional Comment] which earlier versions of Internet Explorer interpreted.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:61--&amp;gt;&lt;br /&gt;
For example&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$document-&amp;gt;addScript(&amp;quot;...demo.js&amp;quot;, array(&#039;conditional&#039;=&amp;gt;&#039;lt IE 9&#039;));&lt;br /&gt;
// leads to&lt;br /&gt;
// &amp;lt;!--[if lt IE 9]&amp;gt;&amp;lt;script src=&amp;quot;...demo.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;![endif]--&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:62--&amp;gt;&lt;br /&gt;
The &#039;&#039;$attributes&#039;&#039; parameter should also be an array, and these are mapped to be HTML attributes of the &#039;&#039;&amp;lt;script&amp;gt;&#039;&#039; or &#039;&#039;&amp;lt;link&amp;gt;&#039;&#039; element. For example,&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$document-&amp;gt;addScript(&amp;quot;...demo.js&amp;quot;, array(), array(&#039;async&#039;=&amp;gt;&#039;async&#039;));&lt;br /&gt;
// leads to&lt;br /&gt;
// &amp;lt;script src=&amp;quot;...demo.js&amp;quot; async&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Adding the Options to Your JavaScript Code == &amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
{{Joomla version|version=3.7|time=and after|comment=&amp;lt;translate&amp;gt;&amp;lt;!--T:50--&amp;gt;&lt;br /&gt;
Only available in Joomla! 3.7 and higher&amp;lt;/translate&amp;gt;|align=left}}&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:63--&amp;gt;&lt;br /&gt;
(Note that these Options are different from the &#039;&#039;$options&#039;&#039; parameter described above).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
Beside adding inline scripts, Joomla! provides a mechanism to store the options in the &amp;quot;optionsStorage&amp;quot;.&lt;br /&gt;
This allows you to nicely manage existing options on the server side and on the client side. It also allows you to place all JavaScript logic into the JavaScript file, which will be cached by browser.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:44--&amp;gt;&lt;br /&gt;
Joomla! uses a special mechanism for &amp;quot;lazy loading&amp;quot; the options on the client side. It doesn&#039;t use inline JavaScript, which is good for page rendering speed, and makes your site more friendly to the Speed Testers (e.g. Google).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:45--&amp;gt;&lt;br /&gt;
The use of &amp;quot;optionsStorage&amp;quot; is preferred over inline JavaScript for adding the script options.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Example of Use&#039;&#039;&#039;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:47--&amp;gt;&lt;br /&gt;
Add the script options to your module:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addScriptOptions(&#039;mod_example&#039;, array(&lt;br /&gt;
    &#039;colors&#039; =&amp;gt; array(&#039;selector&#039; =&amp;gt; &#039;body&#039;, &#039;color&#039; =&amp;gt; &#039;orange&#039;),&lt;br /&gt;
    &#039;sliderOptions&#039; =&amp;gt; array(&#039;selector&#039; =&amp;gt; &#039;.my-slider&#039;, &#039;timeout&#039; =&amp;gt; 300, &#039;fx&#039; =&amp;gt; &#039;fade&#039;)&lt;br /&gt;
));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
Access your options on the client side:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var myOptions = Joomla.getOptions(&#039;mod_example&#039;);&lt;br /&gt;
console.log(myOptions.colors); // Print your options in the browser console.&lt;br /&gt;
console.log(myOptions.sliderOptions);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
Override the options on server side. (Possible until the head rendering.):&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$document  = JFactory::getDocument();&lt;br /&gt;
// Get existing options&lt;br /&gt;
$myOptions = $document-&amp;gt;getScriptOptions(&#039;mod_example&#039;);&lt;br /&gt;
// Change the value&lt;br /&gt;
$myOptions[&#039;colors&#039;] = array(&#039;selector&#039; =&amp;gt; &#039;body&#039;, &#039;color&#039; =&amp;gt; &#039;green&#039;);&lt;br /&gt;
// Set new options&lt;br /&gt;
$document-&amp;gt;addScriptOptions(&#039;mod_example&#039;, $myOptions);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Passing Language Strings to JavaScript == &amp;lt;!--T:64--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:65--&amp;gt;&lt;br /&gt;
There are cases when you may want to output an error message in your JavaScript code and want to use the Joomla mechanism of language strings. You could manage this by using addScriptOptions to pass down each language string you need, but Joomla provides a more succinct solution. &amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:66--&amp;gt;&lt;br /&gt;
To pass a language string to JavaScript do in your PHP code, for example,&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;JText::script(&#039;JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN&#039;);&#039;&#039;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:67--&amp;gt;&lt;br /&gt;
Then in your JavaScript code you can do:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;var message = Joomla.JText._(&#039;JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN&#039;);&#039;&#039;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:68--&amp;gt;&lt;br /&gt;
to obtain in the user&#039;s language the text message associated with the language constant.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:69--&amp;gt;&lt;br /&gt;
Obviously certain language strings have embedded %s characters, so in your JavaScript code you will have to handle that, eg using an external JavaScript sprintf library or string replace, etc.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Inserting Inline Scripts from Within a PHP File == &amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
If your JavaScript or CSS are generated using PHP, you can add the script or style sheet directly into the head of your document:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
&lt;br /&gt;
// Add Javascript&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(&#039;&lt;br /&gt;
    window.event(&amp;quot;domready&amp;quot;, function() {&lt;br /&gt;
        alert(&amp;quot;An inline JavaScript Declaration&amp;quot;);&lt;br /&gt;
    });&lt;br /&gt;
&#039;);&lt;br /&gt;
&lt;br /&gt;
// Add styles&lt;br /&gt;
$style = &#039;body {&#039;&lt;br /&gt;
        . &#039;background: #00ff00;&#039;&lt;br /&gt;
        . &#039;color: rgb(0,0,255);&#039;&lt;br /&gt;
        . &#039;}&#039;;&lt;br /&gt;
$document-&amp;gt;addStyleDeclaration($style);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== JavaScript Example === &amp;lt;!--T:34--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:70--&amp;gt;&lt;br /&gt;
For example, the following code is used to define a custom tool tip that takes advantage of Mootools.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
function getToolTipJS($toolTipVarName, $toolTipClassName){&lt;br /&gt;
    $javascript = &#039;window.addEvent(\&amp;quot;domready\&amp;quot;, function(){&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t&amp;quot;  .&#039;var $toolTipVarName = new Tips($$(&amp;quot;&#039; . $toolTipVarName .&#039;&amp;quot;), {&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t&amp;quot;   .&#039;className: &amp;quot;&#039; .$toolTipClassName .&#039;&amp;quot;,&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t&amp;quot;   .&#039;initialize: function(){&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t\t&amp;quot;    .&#039;this.fx = new Fx.Style(this.toolTip, &amp;quot;opacity&amp;quot;, {duration: 500, wait: false}).set(0);&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t&amp;quot;   .&#039;},&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t&amp;quot;   .&#039;onShow: function(toolTip){&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t\t&amp;quot;    .&#039;this.fx.start(1);&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t&amp;quot;   .&#039;},&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t&amp;quot;   .&#039;onHide: function(toolTip) {&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t\t&amp;quot;    .&#039;this.fx.start(0);&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t\t&amp;quot;   .&#039;}&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &amp;quot;\t&amp;quot;  .&#039;});&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
    $javascript .= &#039;});&#039; .&amp;quot;\n\n&amp;quot;;&lt;br /&gt;
    return $javascript;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addStyleSheet(&amp;quot;/joomla/components/com_mycustomcomponent/css/mytooltip.css&amp;quot;,&#039;text/css&#039;,&amp;quot;screen&amp;quot;);&lt;br /&gt;
$document-&amp;gt;addScriptDeclaration(getToolTipJS(&amp;quot;mytool&amp;quot;,&amp;quot;MyToolTip&amp;quot;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
Note that in order for this JavaScript to be useful, it is necessary to include the appropriate class name in the HTML, as well as providing the &#039;&#039;mytooltip.css&#039;&#039; file. Both are outside the scope of this article.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== CSS Examples === &amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
This is also useful if you are inserting a form field of CSS into your code. For example, in a module you might want a user to choose the colour of the border. Call the form field&#039;s value and assign it a variable $bordercolor in mod_example.php. Then in tmpl/default.php you can include the following:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addStyleSheet(&#039;mod_example/mod_example.css&#039;);&lt;br /&gt;
$style = &#039;#example {&lt;br /&gt;
	border-color:#&#039; . $bordercolor . &#039;;&lt;br /&gt;
	}&#039;;&lt;br /&gt;
$document-&amp;gt;addStyleDeclaration( $style );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
Here mod_example.css contains the CSS file of any non-parameter based styles. Then the &#039;&#039;bordercolor&#039;&#039; parameter/form field is added in separately.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Add Custom Tag== &amp;lt;!--T:39--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:40--&amp;gt;&lt;br /&gt;
There will be some occasions where even these functions are not flexible enough, as they are limited to writing the contents of &#039;&#039;&amp;lt;script /&amp;gt;&#039;&#039; or &#039;&#039;&amp;lt;style /&amp;gt;&#039;&#039; tags, and cannot add anything outside those tags. One example would be the inclusion of a style sheet link within conditional comments, so that it is picked up only by Internet Explorer 6 and earlier. To do this, use &#039;&#039;$document-&amp;gt;addCustomTag&#039;&#039;:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$stylelink = &#039;&amp;lt;!--[if lte IE 6]&amp;gt;&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
$stylelink .= &#039;&amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;../css/IEonly.css&amp;quot; /&amp;gt;&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
$stylelink .= &#039;&amp;lt;![endif]--&amp;gt;&#039; .&amp;quot;\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$document = JFactory::getDocument();&lt;br /&gt;
$document-&amp;gt;addCustomTag($stylelink);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:51--&amp;gt;&lt;br /&gt;
If it was necessary to include other conditional CSS, always include the &#039;&#039;addCustomTag&#039;&#039; method after it is declared.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Sample Module Code == &amp;lt;!--T:71--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:72--&amp;gt;&lt;br /&gt;
Below is the code for a simple Joomla module which you can install and run to demonstrate adding CSS and JavaScript, and can adapt to experiment with the concepts above. If you are unsure about development and installing a Joomla module then following the tutorial at [[S:MyLanguage/J3.x:Creating a simple module/Introduction| Creating a simple module ]] will help.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:73--&amp;gt;&lt;br /&gt;
In a folder mod_css_js_demo create the following 4 files:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;mod_css_js_demo.xml&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.1&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;css js demo&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.1&amp;lt;/version&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Code for including JS and CSS links&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_css_js_demo&amp;quot;&amp;gt;mod_css_js_demo.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;demo.css&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;demo.js&amp;lt;/filename&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;mod_css_js_demo.php&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted Access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
$document = Factory::getDocument();&lt;br /&gt;
&lt;br /&gt;
$options = array(&amp;quot;version&amp;quot; =&amp;gt; &amp;quot;auto&amp;quot;);&lt;br /&gt;
$attributes = array(&amp;quot;defer&amp;quot; =&amp;gt; &amp;quot;defer&amp;quot;);&lt;br /&gt;
$document-&amp;gt;addScript(JURI::root() . &amp;quot;modules/mod_css_js_demo/demo.js&amp;quot;, $options, $attributes);&lt;br /&gt;
$document-&amp;gt;addStyleSheet(JURI::root() . &amp;quot;modules/mod_css_js_demo/demo.css&amp;quot;, $options);&lt;br /&gt;
&lt;br /&gt;
$document-&amp;gt;addScriptOptions(&#039;my_vars&#039;, array(&#039;id&#039; =&amp;gt; &amp;quot;css-js-demo-id2&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
JText::script(&#039;JLIB_HTML_EDIT_MENU_ITEM_ID&#039;);&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;h1 id=&amp;quot;css-js-demo-id1&amp;quot;&amp;gt;Hello World!&amp;lt;/h3&amp;gt;&#039;;&lt;br /&gt;
echo &#039;&amp;lt;button id=&amp;quot;css-js-demo-id2&amp;quot;&amp;gt;Click here!&amp;lt;/button&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;demo.css&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
#css-js-demo-id1 {&lt;br /&gt;
color: red;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;demo.js&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
jQuery(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
	const params = Joomla.getOptions(&#039;my_vars&#039;);&lt;br /&gt;
	console.log(params);&lt;br /&gt;
	console.log(&amp;quot;JS language constant: &amp;quot; + Joomla.JText._(&#039;JLIB_HTML_EDIT_MENU_ITEM_ID&#039;));&lt;br /&gt;
&lt;br /&gt;
	var message = Joomla.JText._(&#039;JLIB_HTML_EDIT_MENU_ITEM_ID&#039;);&lt;br /&gt;
	message = message.replace(&amp;quot;%s&amp;quot;, params.id);&lt;br /&gt;
	document.getElementById(params.id).addEventListener(&amp;quot;click&amp;quot;, function() {alert(message);});&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:74--&amp;gt;&lt;br /&gt;
Zip up the mod_css_js_demo directory to create &#039;&#039;mod_css_js_demo.zip&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:75--&amp;gt;&lt;br /&gt;
Within your Joomla Administrator go to Install Extensions and via the Upload Package File tab, select this zip file to install this sample mod_css_js_demo module.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:76--&amp;gt;&lt;br /&gt;
Make this module visible by editing it (click on it within the Modules page) then:&lt;br /&gt;
# making its status Published&lt;br /&gt;
# selecting a position on the page for it to be shown&lt;br /&gt;
# on the menu assignment tab specify the pages it should appear on&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:77--&amp;gt;&lt;br /&gt;
When you visit the web page, you should see the module in your selected position. It should display:&lt;br /&gt;
* a message &#039;&#039;Hello World!&#039;&#039; which the CSS file should change to display in red&lt;br /&gt;
* a button which when you click it will execute an &#039;&#039;alert()&#039;&#039; showing the language string and variable which were passed down from the PHP code.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:78--&amp;gt;&lt;br /&gt;
Using your browser&#039;s development tools you can also view the &#039;&#039;&amp;lt;script&amp;gt;&#039;&#039; and &#039;&#039;&amp;lt;link&amp;gt;&#039;&#039; elements within the HTML and see the JavaScript output on the console. &amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Component Development]]&lt;br /&gt;
[[Category:Module Development]]&lt;br /&gt;
[[Category:JavaScript]]&lt;br /&gt;
[[Category:CSS]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Using_Joomla_Ajax_Interface&amp;diff=1033483</id>
		<title>Using Joomla Ajax Interface</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Using_Joomla_Ajax_Interface&amp;diff=1033483"/>
		<updated>2024-11-27T10:30:03Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/javascript/com-ajax/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;{{Joomla version|version=3.2|time=and after|comment=&amp;lt;translate&amp;gt;&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
series&amp;lt;/translate&amp;gt;}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{-}}&lt;br /&gt;
&amp;lt;translate&amp;gt;==What is The Joomla Ajax Interface (&#039;&#039;com_ajax&#039;&#039;)== &amp;lt;!--T:1--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
A slim, extensible component to act as an entry point for HTTP requests for stand alone modules and plugins, thus allowing for the potential of Ajax functionality in them. &#039;&#039;com_ajax &#039;&#039;is generally used when you are not the developer of the component that the module or plugin is interacting with.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;NOTE&#039;&#039;&#039; If you are a component developer, you do not need to use &#039;&#039;com_ajax&#039;&#039; to implement Ajax functionality in it. You can do so directly in your component.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
Examples of use cases include, but are not limited to:&lt;br /&gt;
*A module that retrieves data from an external API&lt;br /&gt;
*A module that interacts with a component that you did not develop&lt;br /&gt;
*A plugin that implement API like functionality to allow consumption of data from your site&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;==Anatomy of an Ajax Request== &amp;lt;!--T:5--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;===Required=== &amp;lt;!--T:6--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;option=com_ajax&#039;&#039;&lt;br /&gt;
*&#039;&#039;[module|plugin]=name&#039;&#039;&lt;br /&gt;
*&#039;&#039;format=[json|debug|raw]&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;===Optional=== &amp;lt;!--T:7--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
*&#039;&#039;method=[custom fragment]&#039;&#039; &amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
defaults to &#039;&#039;get&#039;&#039; if omitted.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;===Overview=== &amp;lt;!--T:9--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
All requests begin with &#039;&#039;?option=com_ajax&#039;&#039;, which calls this extension, and must indicate the type of extension to call, and the data format to be returned.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Additional variables and values used by your extension may also be included in the URL.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
For example, a request to &#039;&#039;?option=com_ajax&amp;amp;amp;module=session&#039;&#039; would call &#039;&#039;mod_session&#039;&#039; with results returned in the default format. In contrast,&#039;&#039;?option=com_ajax&amp;amp;amp;plugin=session&amp;amp;amp;format=json&#039;&#039; would trigger the &#039;&#039;onAjaxSession&#039;&#039; plugin group with results returned in JSON.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;==Module Support== &amp;lt;!--T:13--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;===Summary=== &amp;lt;!--T:14--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
Module support is accomplished by calling a method in the module&#039;s &#039;&#039;helper.php&#039;&#039; file.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;===Details=== &amp;lt;!--T:16--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
Module requests must include the &#039;&#039;module&#039;&#039; variable in the URL, paired with the name of the module (i.e. &#039;&#039;module=session&#039;&#039; for &#039;&#039;mod_session&#039;&#039;).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
This value is also used for:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
*The name of the directory to check for the helper file, e.g. &#039;&#039;/modules/mod_session/helper.php&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
*The class name to call, e.g. &#039;&#039;modSessionHelper&#039;&#039;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
Optionally, the &#039;&#039;method&#039;&#039; variable may be included to override the default method prefix of &#039;&#039;get&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:&amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;NOTE&#039;&#039;&#039; All methods must end in &#039;&#039;Ajax&#039;&#039;. For example:&amp;lt;/translate&amp;gt;&lt;br /&gt;
:&#039;&#039;method=mySuperAwesomeMethodToTrigger&#039;&#039; &amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
will call&amp;lt;/translate&amp;gt; &#039;&#039;mySuperAwesomeMethodToTriggerAjax&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
The [https://github.com/Joomla-Ajax-Interface/Ajax-Session-Module Ajax Session Module] is an example module that demonstrates this functionality.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;==Plugin Response== &amp;lt;!--T:25--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;===Summary=== &amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
Plugin support is accomplished by triggering the &#039;&#039;onAjax[Name]&#039;&#039; plugin event.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;===Details=== &amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
Plugin requests must include the &#039;&#039;plugin&#039;&#039; variable in the URL, paired with the name of the plugin event, e.g. &#039;&#039;plugin=session&#039;&#039; for &#039;&#039;onAjaxSession&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
This value is also used for:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:31--&amp;gt;&lt;br /&gt;
*The plugin class name following the &#039;&#039;plgAjax[Name]&#039;&#039; convention.&lt;br /&gt;
*The plugin function name following the &#039;&#039;onAjax[Name]&#039;&#039; convention.&lt;br /&gt;
*The default plugin group is &#039;&#039;ajax&#039;&#039;. You can change it specifying the &#039;&#039;group&#039;&#039; request parameter. (From Joomla! 3.4)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:32--&amp;gt;&lt;br /&gt;
The [https://github.com/Joomla-Ajax-Interface/Ajax-Latest-Articles Ajax Latest Articles plugin] is an example plugin that demonstrates this functionality.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;==Response Format== &amp;lt;!--T:33--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:34--&amp;gt;&lt;br /&gt;
&#039;&#039;format=[json|debug]&#039;&#039; is an optional argument for the results format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:35--&amp;gt;&lt;br /&gt;
*&#039;&#039;json&#039;&#039; for JSON format&lt;br /&gt;
*&#039;&#039;debug&#039;&#039; for human-readable output of the results.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
[[Category:AJAX]]&lt;br /&gt;
[[Category:JavaScript]]&lt;br /&gt;
[[Category:Development]]&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=JSON_Responses_with_JResponseJson&amp;diff=1033482</id>
		<title>JSON Responses with JResponseJson</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=JSON_Responses_with_JResponseJson&amp;diff=1033482"/>
		<updated>2024-11-27T10:27:47Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/javascript/ajax/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
{{version/tutor|3.x}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
This is one of a series of [[API Guides]], which aim to help you understand how to use the Joomla APIs through providing detailed explanations and sample code which you can easily install and run.&lt;br /&gt;
&lt;br /&gt;
A new class, JResponseJson, was added to Joomla! 3 that is able to simplify Ajax requests. As of Joomla! 3.8, the core code was namespaced and aliases were added. (See the &#039;&#039;/libraries/classmap.php&#039;&#039; file at or near line 131.) The JResponseJson class was replaced by the JsonResponse class in the Joomla/CMS/Response namespace.&lt;br /&gt;
&lt;br /&gt;
With that class it is now possible to prepare responses to Ajax requests in a standardized and easy manner.&lt;br /&gt;
&lt;br /&gt;
Have a look at the revised file on [https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Response/JsonResponse.php Github] or in your own site&#039;s files at &#039;&#039;/libraries/src/Response/JsonResponse.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The JsonResponse class will mostly be used in controllers of components where you get the following advantages:&lt;br /&gt;
&lt;br /&gt;
* Using the flag &#039;&#039;success&#039;&#039; the JavaScript code (whether Mootools JRequest.JSON or jQuery.getJSON) can check whether the task was successful or not and react accordingly. (If the request itself fails, the error event of the JavaScript API can be used.)&lt;br /&gt;
* Then the actual response data, if any, can be retrieved from &#039;&#039;data&#039;&#039; in the JSON object, and&lt;br /&gt;
* Optionally a main response message from &#039;&#039;message&#039;&#039;.&lt;br /&gt;
* Additionally, all gathered messages in the JApplication message queue are automatically sent back in &#039;&#039;messages&#039;&#039;. This can be turned off.&lt;br /&gt;
&lt;br /&gt;
Another advantage is that no &#039;&#039;$app-&amp;gt;close();&#039;&#039; is necessary if the Ajax request is done with &#039;&#039;format=json&#039;&#039;. The existing API handles the rest. Just echo the response object at the end of the task.&lt;br /&gt;
&lt;br /&gt;
== How to Use ==&lt;br /&gt;
=== Most Common Cases ===&lt;br /&gt;
Here is an example controller file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class MyController extends JControllerLegacy&lt;br /&gt;
{&lt;br /&gt;
  public function execute()&lt;br /&gt;
  {&lt;br /&gt;
    try&lt;br /&gt;
    {&lt;br /&gt;
      $anyParam = JFactory::getApplication()-&amp;gt;input-&amp;gt;get(&#039;anyparam&#039;);&lt;br /&gt;
&lt;br /&gt;
      $result = $this-&amp;gt;getModel(&#039;example&#039;)-&amp;gt;createSomething($anyParam);&lt;br /&gt;
&lt;br /&gt;
      echo new JsonResponse($result);&lt;br /&gt;
    }&lt;br /&gt;
    catch(Exception $e)&lt;br /&gt;
    {&lt;br /&gt;
      echo new JsonResponse($e);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the default case, the return value of something that has been calculated by the model is simply pushed into a new JsonResponse object and written to the output. This will automatically create a JSON-encoded string as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;success&amp;quot;:true,&amp;quot;message&amp;quot;:null,&amp;quot;messages&amp;quot;:null,&amp;quot;data&amp;quot;:{&amp;quot;myfirstcustomparam&amp;quot;:1,&amp;quot;mysecondcustomparam&amp;quot;:42, ...}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;&#039;data&#039;&#039; field, you can send any array, object or value you want and the &#039;&#039;success&#039;&#039; flag is automatically set to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If any exception occurred in the model, this exception is simply passed directly to a new JsonResponse object which would create the following output:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;success&amp;quot;:false,&amp;quot;message&amp;quot;:&amp;quot;This is the message of the exception&amp;quot;,&amp;quot;messages&amp;quot;:null,&amp;quot;data&amp;quot;:null}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since it is an exception the &#039;&#039;success&#039;&#039; flag is automatically set to &#039;&#039;false&#039;&#039; and the message of the exception becomes the main response message.&lt;br /&gt;
&lt;br /&gt;
=== Additional Options ===&lt;br /&gt;
If no exception is passed as the first argument of the JsonResponse constructor, you can specify an arbitrary main response message by passing a string as the second argument:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo new JsonResponse($result, JText::_(&#039;COM_COMPONENT_MY_TASK_SUCCESS&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
which creates, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;success&amp;quot;:true,&amp;quot;message&amp;quot;:&amp;quot;The request was successful.&amp;quot;,&amp;quot;messages&amp;quot;:null,&amp;quot;data&amp;quot;:{&amp;quot;myfirstcustomparam&amp;quot;:1,&amp;quot;mysecondcustomparam&amp;quot;:42, ...}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also set the error flag to &#039;&#039;true&#039;&#039; with the help of the third argument (&#039;&#039;$error&#039;&#039;):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo new JsonResponse($result, JText::_(&#039;COM_COMPONENT_MY_TASK_ERROR&#039;), true);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
which creates, for example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;success&amp;quot;:false,&amp;quot;message&amp;quot;:&amp;quot;There was an error.&amp;quot;,&amp;quot;messages&amp;quot;:null,&amp;quot;data&amp;quot;:{&amp;quot;myfirstcustomparam&amp;quot;:1,&amp;quot;mysecondcustomparam&amp;quot;:42, ...}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In this way you can also send some data back.&lt;br /&gt;
&lt;br /&gt;
Regardless of having an error response or a success response, JsonResponse sends all messages back to the client that have been gathered in the application object:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$app = JFactory::getApplication();&lt;br /&gt;
// Some code ($result = ...)&lt;br /&gt;
$app-&amp;gt;enqueueMessage(&#039;This part was successful&#039;);&lt;br /&gt;
// Some more code&lt;br /&gt;
$app-&amp;gt;enqueueMessage(&#039;Here was a small warning&#039;. &#039;warning&#039;);&lt;br /&gt;
&lt;br /&gt;
echo new JsonResponse($result, &#039;Main response message&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This results in:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;json&amp;quot;&amp;gt;&lt;br /&gt;
{&amp;quot;success&amp;quot;:true,&amp;quot;message&amp;quot;:&amp;quot;Main response message&amp;quot;,&amp;quot;messages&amp;quot;:&amp;quot;&amp;lt;&amp;lt;all the encoded messages of $app&amp;gt;&amp;gt;&amp;quot;,&amp;quot;data&amp;quot;:{&amp;quot;myfirstcustomparam&amp;quot;:1,&amp;quot;mysecondcustomparam&amp;quot;:42, ...}}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the advantage of that below in the JavaScript section.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to send the messages back (rather they stay in the session), set the fourth argument (&#039;&#039;$ignoreMessages&#039;&#039;) of the constructor to &#039;&#039;true&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Corresponding JavaScript Code ===&lt;br /&gt;
Here is some sample JavaScript that can be used on the client side together with JsonResponse on the server side.&lt;br /&gt;
The example is written with Mootools code. Something similar can also be done with jQuery or any other JavaScript library for Ajax requests.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var req = new Request.JSON({&lt;br /&gt;
	method: &#039;post&#039;,&lt;br /&gt;
	url: &#039;index.php?option=com_component&amp;amp;task=mycontroller.execute&amp;amp;format=json&#039;,&lt;br /&gt;
	onSuccess: function(r)&lt;br /&gt;
	{&lt;br /&gt;
		if (!r.success &amp;amp;&amp;amp; r.message)&lt;br /&gt;
		{&lt;br /&gt;
			// Success flag is set to &#039;false&#039; and main response message given&lt;br /&gt;
			// so you can alert it or insert it into some HTML element&lt;br /&gt;
			alert(r.message);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		if (r.messages)&lt;br /&gt;
		{&lt;br /&gt;
			// All the enqueued messages of the $app object can simple be&lt;br /&gt;
			// rendered by the respective helper function of Joomla!&lt;br /&gt;
			// They will automatically be displayed at the messages section of the template&lt;br /&gt;
			Joomla.renderMessages(r.messages);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		if (r.data)&lt;br /&gt;
		{&lt;br /&gt;
			// Here you can access all the data of your response&lt;br /&gt;
			alert(r.data.myfirstcustomparam);&lt;br /&gt;
			alert(r.data.mysecondcustomparam);&lt;br /&gt;
		}&lt;br /&gt;
	}.bind(this),&lt;br /&gt;
	onFailure: function(xhr)&lt;br /&gt;
	{&lt;br /&gt;
		// Reaching this point means that the Ajax request itself was not successful&lt;br /&gt;
		// So JsonResponse was never called&lt;br /&gt;
		alert(&#039;Ajax error&#039;);&lt;br /&gt;
	}.bind(this),&lt;br /&gt;
	onError: function(text, error)&lt;br /&gt;
	{&lt;br /&gt;
		// Reaching this point means that the Ajax request was answered by the server, but&lt;br /&gt;
		// the response was not valid JSON. (This happens sometimes if there were PHP errors,&lt;br /&gt;
		// warnings or notices during the development process of a new Ajax request.)&lt;br /&gt;
		alert(error + &amp;quot;\n\n&amp;quot; + text);&lt;br /&gt;
	}.bind(this)&lt;br /&gt;
});&lt;br /&gt;
req.post(&#039;anyparam=myvalue&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Best Practice ==&lt;br /&gt;
As seen above, controller code can be kept simple using JsonResponse. The model is calculating the data which can be passed to JsonResponse afterwards. (You can still modify it in the controller.) If you are developing an MVC component, save such a controller in a file called &#039;&#039;mycontroller.json.php&#039;&#039; and place it inside your &#039;&#039;controllers&#039;&#039; folder. That controller is automatically executed if your request URL contains &#039;&#039;format=json&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Note that there is no need for closing the application (&#039;&#039;$app-&amp;gt;close();&#039;&#039;) because the architecture of Joomla! handles that for you.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class MyController extends JControllerLegacy&lt;br /&gt;
{&lt;br /&gt;
  public function execute()&lt;br /&gt;
  {&lt;br /&gt;
    try&lt;br /&gt;
    {&lt;br /&gt;
      $anyParam = JFactory::getApplication()-&amp;gt;input-&amp;gt;get(&#039;anyparam&#039;);&lt;br /&gt;
&lt;br /&gt;
      $count = $this-&amp;gt;getModel(&#039;example&#039;)-&amp;gt;countSomething($anyParam);&lt;br /&gt;
&lt;br /&gt;
      echo new JsonResponse($count);&lt;br /&gt;
    }&lt;br /&gt;
    catch(Exception $e)&lt;br /&gt;
    {&lt;br /&gt;
      echo new JsonResponse($e);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Additional Note===&lt;br /&gt;
If you want to support users without JavaScript by doing the same task with a normal request and a final redirect back to the page, there is not much you have do additionally. Just create another controller (with a name such as &#039;&#039;mycontroller.php&#039;&#039;) and code like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class MyController extends JControllerLegacy&lt;br /&gt;
{&lt;br /&gt;
  public function execute()&lt;br /&gt;
  {&lt;br /&gt;
    $app = JFactory::getApplication();&lt;br /&gt;
    $app-&amp;gt;setRedirect(JRoute::_(&#039;index.php?option=com_mycomponent&amp;amp;view=myview&#039;, false));&lt;br /&gt;
&lt;br /&gt;
    try&lt;br /&gt;
    {&lt;br /&gt;
      $anyParam = JFactory::getApplication()-&amp;gt;input-&amp;gt;get(&#039;anyparam&#039;);&lt;br /&gt;
&lt;br /&gt;
      $count = $this-&amp;gt;getModel(&#039;example&#039;)-&amp;gt;countSomething($anyParam);&lt;br /&gt;
&lt;br /&gt;
      $app-&amp;gt;setMessage(JText::plural(&#039;COM_COMPONENT_COUNT_TASK&#039;, $count));&lt;br /&gt;
    }&lt;br /&gt;
    catch(Exception $e)&lt;br /&gt;
    {&lt;br /&gt;
      $app-&amp;gt;setMessage(JText::sprintf(&#039;COM_COMPONENT_COUNT_TASK_ERROR&#039;, $e-&amp;gt;getMessage()), &#039;error&#039;);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
No changes are necessary in the model!&lt;br /&gt;
&lt;br /&gt;
Depending on whether you do the request with &#039;&#039;format=json&#039;&#039; (Ajax-Request) or via normal request (without the &#039;&#039;format&#039;&#039; parameter), the correct controller is executed automatically and the response is prepared accordingly.&lt;br /&gt;
&lt;br /&gt;
== Sample Component Code ==&lt;br /&gt;
Below is the code for a simple Joomla component which you can install and run to demonstrate use of the JReponseJson functionality. Place the following 3 files into a folder called &amp;quot;com_jresponse_json_demo&amp;quot;. Then zip up the folder to create &amp;lt;tt&amp;gt;com_jresponse_json_demo.zip&amp;lt;/tt&amp;gt; and install this as a component on your Joomla instance. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;com_jresponse_json_demo.xml&amp;lt;/tt&amp;gt; Manifest file for the component&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;component&amp;quot; version=&amp;quot;3.1.0&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;name&amp;gt;com_jresponse_json_demo&amp;lt;/name&amp;gt;&lt;br /&gt;
	&amp;lt;version&amp;gt;1.0.0&amp;lt;/version&amp;gt;&lt;br /&gt;
	&amp;lt;description&amp;gt;Demo of jresponse_json&amp;lt;/description&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
	&amp;lt;administration&amp;gt;&lt;br /&gt;
	&amp;lt;/administration&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;files folder=&amp;quot;site&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;jresponse_json_demo.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
		&amp;lt;filename&amp;gt;calc.js&amp;lt;/filename&amp;gt;&lt;br /&gt;
	&amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;jresponse_json_demo.php&amp;lt;/tt&amp;gt; PHP file which displays the form and handles the Ajax request.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
&lt;br /&gt;
$app = Factory::getApplication();  &lt;br /&gt;
$input = $app-&amp;gt;input;&lt;br /&gt;
&lt;br /&gt;
$task = $input-&amp;gt;get(&amp;quot;task&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;cmd&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
function divide($a, $b)  &lt;br /&gt;
{&lt;br /&gt;
	if ($b == 0)&lt;br /&gt;
	{&lt;br /&gt;
		throw new Exception(&#039;Division by zero!&#039;);&lt;br /&gt;
	}&lt;br /&gt;
	return $a/$b;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ($task == &amp;quot;divide&amp;quot;) {   // respond to Ajax&lt;br /&gt;
	$x = $input-&amp;gt;get(&amp;quot;x&amp;quot;, 0, &amp;quot;float&amp;quot;);&lt;br /&gt;
	$y = $input-&amp;gt;get(&amp;quot;y&amp;quot;, 0, &amp;quot;float&amp;quot;);&lt;br /&gt;
	$app-&amp;gt;enqueueMessage(&amp;quot;Enqueued notice&amp;quot;, &amp;quot;notice&amp;quot;);&lt;br /&gt;
	$app-&amp;gt;enqueueMessage(&amp;quot;Enqueued warning&amp;quot;, &amp;quot;warning&amp;quot;);&lt;br /&gt;
	try &lt;br /&gt;
	{&lt;br /&gt;
		$result = divide($x, $y);&lt;br /&gt;
		echo new JResponseJson($result, &amp;quot;It worked!&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
	catch (Exception $e)&lt;br /&gt;
	{&lt;br /&gt;
		echo new JResponseJson($e);&lt;br /&gt;
	}&lt;br /&gt;
} else {   // normal HTTP GET - display the form&lt;br /&gt;
	JHtml::_(&#039;jquery.framework&#039;);  // use JQuery for Ajax call&lt;br /&gt;
	$document = JFactory::getDocument();&lt;br /&gt;
	$document-&amp;gt;addScript(JUri::root() . &amp;quot;components/com_jresponse_json_demo/calc.js&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	echo &#039;&amp;lt;label&amp;gt;x&amp;lt;/label&amp;gt;&amp;lt;input id=&amp;quot;x&amp;quot; type=&amp;quot;number&amp;quot; step=&amp;quot;any&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
	echo &#039;&amp;lt;label&amp;gt;y&amp;lt;/label&amp;gt;&amp;lt;input id=&amp;quot;y&amp;quot; type=&amp;quot;number&amp;quot; step=&amp;quot;any&amp;quot;&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
	echo &#039;&amp;lt;button onclick=&amp;quot;calculate();&amp;quot;&amp;gt;Divide!&amp;lt;/button&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
	echo &#039;&amp;lt;label&amp;gt;answer&amp;lt;/label&amp;gt;&amp;lt;input id=&amp;quot;answer&amp;quot; type=&amp;quot;text&amp;quot; readonly&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;calc.js&amp;lt;/tt&amp;gt; Javascript file which initiates the Ajax request and handles the response.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
function calculate() {&lt;br /&gt;
	x = document.getElementById(&amp;quot;x&amp;quot;).value;&lt;br /&gt;
	y = document.getElementById(&amp;quot;y&amp;quot;).value;&lt;br /&gt;
	jQuery.ajax({	// by default jQuery sends Ajax requests to the same URL as the current page&lt;br /&gt;
        	data: { task: &amp;quot;divide&amp;quot;, format: &amp;quot;json&amp;quot;, x: x, y: y },&lt;br /&gt;
		})&lt;br /&gt;
		.done(function(result, textStatus, jqXHR)&lt;br /&gt;
		{&lt;br /&gt;
			if (result.success)&lt;br /&gt;
			{&lt;br /&gt;
				jQuery(&amp;quot;#answer&amp;quot;).val(result.data); &lt;br /&gt;
				console.log(&amp;quot;Message from server was &amp;quot; + result.message);&lt;br /&gt;
			}&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
				alert(result.message);&lt;br /&gt;
			}&lt;br /&gt;
			// display the enqueued messages in the message area&lt;br /&gt;
			Joomla.renderMessages(result.messages);&lt;br /&gt;
		})&lt;br /&gt;
		.fail(function(jqXHR, textStatus, errorThrown)&lt;br /&gt;
		{&lt;br /&gt;
			console.log(&#039;ajax call failed&#039; + textStatus);&lt;br /&gt;
		});&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the component is installed, navigate to your site home page and add the following parameter to the URL  &amp;lt;tt&amp;gt;?option=&amp;quot;com_jresponse_json_demo&amp;quot;&amp;lt;/tt&amp;gt; to navigate to this component. The component prompts for 2 values, x and y, and when you click on the Divide button it makes an Ajax call to the server. The server performs the calculation, including checking for division by zero, and then returns the answer using JReponseJson. &lt;br /&gt;
&lt;br /&gt;
The server also includes 2 enqueued messages in the response, which the javascript displays in the message area by calling &amp;lt;tt&amp;gt;Joomla.renderMessages()&amp;lt;/tt&amp;gt; (which is a javascript function found in the Joomla core.js file). &lt;br /&gt;
&lt;br /&gt;
(The server code has been designed to focus on the JResponseJson API. If you are developing a genuine Joomla component then you should use the Joomla Form API and MVC approach as outlined in [[Basic form guide]].)&lt;br /&gt;
&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
Another example of using JReponseJson can be found in [[J3.x:Developing_an_MVC_Component/Adding_AJAX]].&lt;br /&gt;
&lt;br /&gt;
Ajax can also be used in Joomla Modules and Plugins, as described in [[Using Joomla Ajax Interface]].&lt;br /&gt;
&lt;br /&gt;
[[Category:AJAX]]&lt;br /&gt;
[[Category:Component Development]]&lt;br /&gt;
[[Category:Extension development]]&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Accessing_the_current_user_object&amp;diff=1033481</id>
		<title>Accessing the current user object</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Accessing_the_current_user_object&amp;diff=1033481"/>
		<updated>2024-11-27T10:19:01Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/user/ Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
{{version/tutor|2.5,3.x}}&lt;br /&gt;
== Overview ==&lt;br /&gt;
This is one of a series of [[API Guides]] that aim to help you understand how to use the Joomla APIs through providing detailed explanations and sample code that you can easily install and run.&lt;br /&gt;
&lt;br /&gt;
This page describes the functionality associated with the Joomla &amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt; class, accessible via the &amp;lt;tt&amp;gt;User&amp;lt;/tt&amp;gt; API. At the bottom of the page there is also the code of a module that you can install to demonstrate some of this functionality.&lt;br /&gt;
&lt;br /&gt;
In general, the &amp;quot;user&amp;quot; represents the identity of someone who can log on to a Joomla instance, whether that be the Frontend, Backend (Administrator functionality) or both. Associated with the user is&lt;br /&gt;
# static information such as username and email address, as well as user preferences regarding language, preferred editor, etc.&lt;br /&gt;
# dynamic information such as the last logon date/time&lt;br /&gt;
# privileges data, specifying the privileges that each user has, which allow him/her to perform actions on items within the Joomla instance.&lt;br /&gt;
&lt;br /&gt;
The Joomla user APIs allow you to view the user account attributes, modify those attributes, check user privileges, delete user accounts and perform user account management functions such as block an account.&lt;br /&gt;
&lt;br /&gt;
Setting some of the user attributes impacts the user&#039;s ability to log on – e.g. blocking the account or changing the password. However, the User API code won&#039;t include other actions that you may need to take in conjunction with that – e.g. sending users an email to warn them that they&#039;re blocked.&lt;br /&gt;
&lt;br /&gt;
== Basic Operations ==&lt;br /&gt;
To get the user object for the currently logged-on user:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
$user = Factory::getUser();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These two lines are equivalent to the following in the old class naming convention:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user = JFactory::getUser();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If no user is logged on then Factory::getUser() returns a &amp;quot;blank&amp;quot; user object, with the id field set to 0 (zero).&lt;br /&gt;
&lt;br /&gt;
To get information about any other registered user you can call the function with a user &amp;lt;tt&amp;gt;id&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;username&amp;lt;/tt&amp;gt;, e.g. for user with &amp;lt;tt&amp;gt;id&amp;lt;/tt&amp;gt; 99;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user = JFactory::getUser(99);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you have the user object, you can display information about the user. For example, this code displays the current user&#039;s name, email and user name:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
echo &amp;quot;&amp;lt;p&amp;gt;This user&#039;s name is {$user-&amp;gt;name}, email is {$user-&amp;gt;email}, and username is {$user-&amp;gt;username}&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== User Object Properties ==&lt;br /&gt;
Joomla stores some of the data items associated with a user in fixed fields in the users table, and other data items in a params field within the users table. This is then reflected in what data items you have available as properties of the user object, and what data items you must use the params property to access.&lt;br /&gt;
&lt;br /&gt;
With regard to the admin Users functionality, generally the data items in the fixed fields are in the first tab in the admin Users / Edit form (currently named &amp;quot;Account Details&amp;quot;), and the attributes stored in the params are visible in a subsidiary tab (currently named &amp;quot;Basic Settings&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
These are the properties automatically generated on a call to getUser(), in the order defined in the API documentation&lt;br /&gt;
* id - The unique, numerical user id. (In other Joomla database tables this id is used as the foreign key to point to the associated user record).&lt;br /&gt;
* name - The name of the user. (e.g. Vint Cerf)&lt;br /&gt;
* username - The login/screen name of the user. (e.g. shmuffin1979)&lt;br /&gt;
* email - The email address of the user. (e.g. crashoverride@hackers.com)&lt;br /&gt;
* password - The encrypted version of the user&#039;s password&lt;br /&gt;
* password_clear - Set to the user&#039;s password only when it is being changed. Otherwise, remains blank.&lt;br /&gt;
* block - Set to &#039;1&#039; when the user is set to &#039;blocked&#039; in Joomla (i.e. prevented from logging on)&lt;br /&gt;
* sendEmail - Specifies whether this user should receive system emails or not&lt;br /&gt;
* registerDate - Set to the date when the user was first registered.&lt;br /&gt;
* lastvisitDate - Set to the date the user last visited the site.&lt;br /&gt;
* activation - an activation token. This is used when the site allows users to self-register. To complete account setup, an email is sent to the person who has self-registered, and the link embedded in the email contains this activation token.&lt;br /&gt;
* params - a json string of name/value pairs for the subsidiary user attributes (see below).&lt;br /&gt;
* groups - an associative array of group id =&amp;gt; (string) group id for the user groups that this user is a member of&lt;br /&gt;
* guest - If the user is not logged in, this variable will be set to &#039;1&#039;. The other variables will be unset or default values.&lt;br /&gt;
* lastResetTime - Set to the last time the password was reset.&lt;br /&gt;
* resetCount - Counts the number of password resets.&lt;br /&gt;
* requireReset - indicates that this user will be forced to reset the password the next time they log in.&lt;br /&gt;
&lt;br /&gt;
The user attributes that are stored in the params field in the database, and that are available via &amp;lt;tt&amp;gt;$user-&amp;gt;getParam()&amp;lt;/tt&amp;gt; are the following.&lt;br /&gt;
* admin_style – the id of the template on the Backend.&lt;br /&gt;
* admin_language – the language tag of the language on the Backend&lt;br /&gt;
* language – the language tag of the language on the Frontend&lt;br /&gt;
* editor – the preferred editor&lt;br /&gt;
* timezone – the user&#039;s selected timezone (one of the standard PHP time zones). The timezone is also available via &amp;lt;tt&amp;gt;getTimezone()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For example, to get the user&#039;s preferred Frontend language call the &amp;lt;tt&amp;gt;getParam()&amp;lt;/tt&amp;gt; member function of the user object, passing in the name of the parameter you want (i.e. &#039;language&#039;) along with a default value in case it is blank.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
$user = Factory::getUser();&lt;br /&gt;
$language = $user-&amp;gt;getParam(&#039;language&#039;, &#039;the default&#039;);&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;&amp;lt;p&amp;gt;Your Frontend language is set to {$language}.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Determining Status ==&lt;br /&gt;
Frequently, you will just want to make sure the user is logged in before continuing. The &#039;guest&#039; property will be set to &#039;1&#039; when the current user is not logged in. When the user is authenticated, &#039;guest&#039; will be set to &#039;0&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
if ($user-&amp;gt;guest) {&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;You must login to see the content. I want your email address.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
} else {&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;You are logged in, you can see the content.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(If you&#039;ve passed a userid/username to getUser() to find the user object of another user on the system, then note that guest does not indicate whether this user is &amp;quot;logged on&amp;quot; or not (in the sense of there being a current session cookie for that user); guest set to 0 is more an indication that a valid user record has been loaded.)&lt;br /&gt;
&lt;br /&gt;
== Privileges ==&lt;br /&gt;
Not all users are given equal rights. For instance, a Super Administrator may be able to edit anyone&#039;s content, while a Publisher may only be able to edit their own. Certain articles may be confidential and may be viewed only by users who have permission to view them.&lt;br /&gt;
&lt;br /&gt;
There are 4 method calls in the User API relating to privileges&lt;br /&gt;
&lt;br /&gt;
=== authorise() ===&lt;br /&gt;
The &amp;lt;tt&amp;gt;authorise()&amp;lt;/tt&amp;gt; member function can be used to determine if the current user has permission to do a certain task. The first parameter is used to identify which task we wish to check being allowed. The second represents the component we wish to retrieve the ACL information from.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user = JFactory::getUser();&lt;br /&gt;
&lt;br /&gt;
if ($user-&amp;gt;authorise(&#039;core.edit&#039;, &#039;com_content&#039;))&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;You may edit all content.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;You may not edit all content.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ($user-&amp;gt;authorise(&#039;core.edit.own&#039;, &#039;com_content&#039;))&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;You may edit your own content.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;&amp;lt;p&amp;gt;You may not edit your own content.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== getAuthorisedCategories() ===&lt;br /&gt;
You call getAuthorisedCategories() passing in the component and the action you want to perform, and the method returns an array of category ids on which this user can perform the action. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user-&amp;gt;getAuthorisedCategories(&#039;com_content&#039;, &#039;core.delete&#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
returns an array of category ids of com_content categories which this user can delete.&lt;br /&gt;
&lt;br /&gt;
=== getAuthorisedGroups() ===&lt;br /&gt;
&amp;lt;tt&amp;gt;$user-&amp;gt;getAuthorisedGroups()&amp;lt;/tt&amp;gt; returns an array of User Group ids which this user is within. You can see the User Group ids by navigating to the admin Users / Groups page.&lt;br /&gt;
&lt;br /&gt;
=== getAuthorisedViewLevels() ===&lt;br /&gt;
&amp;lt;tt&amp;gt;$user-&amp;gt;getAuthorisedViewLevels()&amp;lt;/tt&amp;gt; returns an array of Viewing Access Levels ids (which you can see by navigating to the admin Users / Viewing Access Levels page). Generally components that want to restrict viewing pages assign an Access Level to each item – one of the Viewing Access Levels which you see on that admin page – and then store the id of the assigned access level against the item in a database field called Access within the item&#039;s database table. Then to check if a given user may view that item you would check if the value in the Access database field was within the array of AuthorisedViewLevels for that user.&lt;br /&gt;
&lt;br /&gt;
For example, if you wanted to restrict an article called &amp;quot;article50&amp;quot; to a Viewing Access Level called Special (with an id of 3), then you would put 3 in the Access field of the Content record for article50, and a user would be allowed to view it if the array returned by getAuthorisedViewLevels() included the element 3.&lt;br /&gt;
&lt;br /&gt;
== Database Operations ==&lt;br /&gt;
The diagram below shows how you can use the User API to update user data. Black arrows indicate flow of control: green arrows indicate direction of data.&lt;br /&gt;
&lt;br /&gt;
Note that the editing of user data is managed within the Joomla admin Users functionality (com_users component), where there are many checks performed to ensure that users can perform only operations that they are authorised to perform. For example, general users may not grant themselves additional privileges. &#039;&#039;&#039;If you use the User APIs then the vast majority of these validations are not performed, so you will likely have to build in additional validation checks yourself.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The User class uses the Joomla Table class to perform CRUD operations at the database level. Operations which change the User record will cause [[Plugin/Events/User|Plugin User Events]] to be raised.&lt;br /&gt;
&lt;br /&gt;
[[File:User_db.jpg|User Database-related methods]]&lt;br /&gt;
&lt;br /&gt;
=== load() ===&lt;br /&gt;
Use &amp;lt;tt&amp;gt;load()&amp;lt;/tt&amp;gt; to load in from the database the attributes of a user record (identified by id) from the database. The User class code will read the data from the database and (assuming it&#039;s a valid user) will store the attributes in the class properties, including the params field which stores the additional attributes. You can then access these properties directly, e.g. &amp;lt;tt&amp;gt;$user-&amp;gt;name&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
What &amp;lt;tt&amp;gt;load()&amp;lt;/tt&amp;gt; does is thus similar to &amp;lt;tt&amp;gt;Factory::getUser($id)&amp;lt;/tt&amp;gt;, except that with &amp;lt;tt&amp;gt;load()&amp;lt;/tt&amp;gt; you need to have created the User instance first with &amp;lt;tt&amp;gt;new User()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== bind() ===&lt;br /&gt;
Use &amp;lt;tt&amp;gt;bind()&amp;lt;/tt&amp;gt; if you have an associative array $data of property names to property values, e.g. &amp;lt;tt&amp;gt;array(&#039;name&#039; =&amp;gt; &#039;Vint Cerf&#039;, &#039;username&#039; =&amp;gt; &#039;shmuffin1979&#039;)&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;bind()&amp;lt;/tt&amp;gt; method will then update the local properties with the values passed in.&lt;br /&gt;
&lt;br /&gt;
You can similarly set the values of the properties directly &amp;lt;tt&amp;gt;$user-&amp;gt;name = &#039;Vint Cerf&#039;&amp;lt;/tt&amp;gt; or the params property via &amp;lt;tt&amp;gt;setParams()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== save() ===&lt;br /&gt;
Use &amp;lt;tt&amp;gt;save()&amp;lt;/tt&amp;gt; to write to the database the updated properties that you have set. The &amp;lt;tt&amp;gt;save()&amp;lt;/tt&amp;gt; code copies the property values into its &#039;table&#039; structure and calls the Table class &amp;lt;tt&amp;gt;bind()&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;store()&amp;lt;/tt&amp;gt; methods to write them to the database.&lt;br /&gt;
&lt;br /&gt;
=== Inserting Records ===&lt;br /&gt;
You can similarly use the above mechanism to insert new user records, the only difference being that you don&#039;t load an existing record from the database first.&lt;br /&gt;
&lt;br /&gt;
=== Deleting Records ===&lt;br /&gt;
To delete a user record you first load it from the database then use the &amp;lt;tt&amp;gt;delete()&amp;lt;/tt&amp;gt; method:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user = Factory::getUser($userid);&lt;br /&gt;
$user-&amp;gt;delete();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Related records in other user tables (such as in #__user_usergroup_map that holds the mapping to user groups and in #__messages which holds user-user messages) are deleted as well, and this operation triggers the events [[Plugin/Events/User#onUserBeforeDelete|onUserBeforeDelete]] and [[Plugin/Events/User#onUserAfterDelete|onUserAfterDelete]] so that plugins can also delete any related user data. However, if the user has, for example, created articles or is associated with a contact record then the references to the user&#039;s id in those records will remain.&lt;br /&gt;
&lt;br /&gt;
== Sample Module Code ==&lt;br /&gt;
Below is the code for a simple Joomla module that you can install and run to demonstrate use of the Joomla User API functionality. If you are unsure about development and installing a Joomla module, following the tutorial at [[S:MyLanguage/J3.x:Creating a simple module/Introduction| Creating a simple module ]] will help.&lt;br /&gt;
&lt;br /&gt;
In a folder mod_sample_user create the following two files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;mod_sample_user.xml&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;extension type=&amp;quot;module&amp;quot; version=&amp;quot;3.1&amp;quot; client=&amp;quot;site&amp;quot; method=&amp;quot;upgrade&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;name&amp;gt;User demo&amp;lt;/name&amp;gt;&lt;br /&gt;
    &amp;lt;version&amp;gt;1.0.1&amp;lt;/version&amp;gt;&lt;br /&gt;
    &amp;lt;description&amp;gt;Code demonstrating use of Joomla User class&amp;lt;/description&amp;gt;&lt;br /&gt;
    &amp;lt;files&amp;gt;&lt;br /&gt;
        &amp;lt;filename module=&amp;quot;mod_sample_user&amp;quot;&amp;gt;mod_sample_user.php&amp;lt;/filename&amp;gt;&lt;br /&gt;
    &amp;lt;/files&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;mod_sample_user.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
defined(&#039;_JEXEC&#039;) or die(&#039;Restricted Access&#039;);&lt;br /&gt;
&lt;br /&gt;
use Joomla\CMS\Factory;&lt;br /&gt;
use Joomla\CMS\Language\LanguageHelper;&lt;br /&gt;
&lt;br /&gt;
$input = Factory::getApplication()-&amp;gt;input;&lt;br /&gt;
&lt;br /&gt;
// find the user - either from username=xxx parameter or current user&lt;br /&gt;
if ($input-&amp;gt;exists(&#039;username&#039;))&lt;br /&gt;
{&lt;br /&gt;
	$username = $input-&amp;gt;get(&#039;username&#039;, &amp;quot;&amp;quot;, &amp;quot;STRING&amp;quot;);&lt;br /&gt;
	echo &amp;quot;Getting details for {$username}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	$user = Factory::getUser($username);&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
	$user = Factory::getUser();&lt;br /&gt;
}&lt;br /&gt;
if ($user-&amp;gt;id == 0)&lt;br /&gt;
{&lt;br /&gt;
	echo &amp;quot;Please logon or provide a valid username as URL parameter&amp;quot;;&lt;br /&gt;
	return;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// output the user&#039;s email address and Frontend language&lt;br /&gt;
$language = $user-&amp;gt;getParam(&#039;language&#039;, &#039;the default&#039;);&lt;br /&gt;
echo &amp;quot;Email address of {$user-&amp;gt;name} is {$user-&amp;gt;email}, Frontend language is {$language}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Set new Frontend language of this user if userlanguage=xxx parameter set&lt;br /&gt;
// This will fail if you try to change the language of a Super User, and you&#039;re not logged on as a Super User&lt;br /&gt;
if ($new_language = $input-&amp;gt;get(&#039;userlanguage&#039;, &amp;quot;&amp;quot;, &amp;quot;STRING&amp;quot;))&lt;br /&gt;
{&lt;br /&gt;
	if (array_key_exists($new_language, LanguageHelper::getContentLanguages()))&lt;br /&gt;
	{&lt;br /&gt;
		$user-&amp;gt;setParam(&#039;language&#039;, $new_language);&lt;br /&gt;
		if ($user-&amp;gt;save())&lt;br /&gt;
		{&lt;br /&gt;
			echo &amp;quot;Language successfully set to {$new_language}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
		}&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			echo &amp;quot;Setting language to {$new_language} failed&amp;lt;br&amp;gt;{$user-&amp;gt;getError()}&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;Setting language to {$new_language} failed - language doesn&#039;t exist&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// if we&#039;re on a single article page, then check if the user can edit the article&lt;br /&gt;
$option = $input-&amp;gt;get(&#039;option&#039;, &amp;quot;&amp;quot;, &amp;quot;cmd&amp;quot;);&lt;br /&gt;
$view = $input-&amp;gt;get(&#039;view&#039;, &amp;quot;&amp;quot;, &amp;quot;string&amp;quot;);&lt;br /&gt;
$id = $input-&amp;gt;get(&#039;id&#039;, 0, &amp;quot;int&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
if ($option == &amp;quot;com_content&amp;quot; &amp;amp;&amp;amp; $view == &amp;quot;article&amp;quot;)&lt;br /&gt;
{&lt;br /&gt;
	if ($user-&amp;gt;authorise(&#039;core.edit&#039;, &amp;quot;com_content.article.{$id}&amp;quot;))&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;{$user-&amp;gt;name} may edit this article&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
		echo &amp;quot;{$user-&amp;gt;name} may not edit this article&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Zip up the mod_sample_user directory to create &amp;lt;tt&amp;gt;mod_sample_user.zip&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Within your Joomla Administrator go to Install Extensions and via the Upload Package File tab select this zip file to install this sample user module.&lt;br /&gt;
&lt;br /&gt;
Make this module visible by editing it (click on it within the Modules page) then:&lt;br /&gt;
# making its status Published&lt;br /&gt;
# selecting a position on the page for it to be shown&lt;br /&gt;
# on the menu assignment tab specify the pages it should appear on&lt;br /&gt;
&lt;br /&gt;
When you visit a site web page then you should see the module in your selected position. The module does the following:&lt;br /&gt;
* gets the user object, and displays the user&#039;s name, email address and preferred Frontend language. You define the user to select by either logging in, or by specifying a parameter to the URL &amp;lt;tt&amp;gt;username=XXX&amp;lt;/tt&amp;gt; (replacing XXX by a valid username on the system).&lt;br /&gt;
* if you specify a URL parameter e.g. &amp;lt;tt&amp;gt;userlanguage=es-ES&amp;lt;/tt&amp;gt; the code will set this language (Peninsular Spanish in this instance) as the preferred Frontend language of the user (provided this language is installed on the system as a Content Language).&lt;br /&gt;
* if you navigate to a page which displays a single article, then the code will output whether this user may edit that article or not.&lt;br /&gt;
&lt;br /&gt;
You can easily adapt the module code to experiment with some of the other API calls described above.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
[https://api.joomla.org/cms-3/classes/Joomla.CMS.Factory.html#method_getUser Joomla 3.9 API reference]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Tutorials]][[Category:Framework]]&lt;br /&gt;
[[Category:Module Development]]&lt;br /&gt;
[[Category:Plugin Development]][[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Plugin/Events/Content&amp;diff=1031314</id>
		<title>Plugin/Events/Content</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Plugin/Events/Content&amp;diff=1031314"/>
		<updated>2024-08-13T08:54:47Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{version/tutor|2.5,3.x|alt=1.5|altlink=J1.5:Plugin/Events/Content|alttitle=this guide for old event names}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/building-extensions/plugins/plugin-events/content Joomla Manual ] instead}}&lt;br /&gt;
&lt;br /&gt;
Content events are triggered during the content creation process. The majority of these events are called in many views many components and modules - they are generally not specific for the com_content component. This list gives a brief description of each event, what their parameters are, and some examples of their use in core plugins.&lt;br /&gt;
&lt;br /&gt;
==onContentPrepare==&lt;br /&gt;
===Description===&lt;br /&gt;
This is the first stage in preparing content for output and is the most common point for content orientated plugins to do their work. Since the article and related parameters are passed by reference, event handlers can modify them prior to display.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;amp;article&amp;lt;/code&amp;gt; A reference to the article that is being rendered by the view (For example: the text of a com_content article can be found with $article-&amp;gt;text).&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;amp;params&amp;lt;/code&amp;gt; A reference to an associative array of relevant parameters. The view determines what it considers to be relevant and passes that information along.&lt;br /&gt;
*&amp;lt;code&amp;gt;page&amp;lt;/code&amp;gt; An integer that determines the &amp;quot;page&amp;quot; of the content that is to be generated. Note that in the context of views that might not generate HTML output, a page is a reasonably abstract concept that depends on the context.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
None. Results are returned by modifying the referenced arguments. Sometimes a boolean might be returned to check for success or failure of the event.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
*&amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/staging/plugins/content/emailcloak/emailcloak.php plugins/content/emailcloak/emailcloak.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==onContentAfterTitle==&lt;br /&gt;
===Description===&lt;br /&gt;
This event only exists in Joomla {{JVer|3.x}}. This is a request for information that should be placed between the content title and the content body. Although parameters are passed by reference, this is not the event to modify article data. Use onContentPrepare for that purpose. Note this event has special purpose in com_content for use in handling the introtext.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
See the onContentPrepare event for additional discussion of these parameters.&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;amp;article&amp;lt;/code&amp;gt; The article that is being rendered by the view.&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;amp;params&amp;lt;/code&amp;gt; An associative array of relevant parameters.&lt;br /&gt;
*&amp;lt;code&amp;gt;limitstart&amp;lt;/code&amp;gt; An integer that determines the &amp;quot;page&amp;quot; of the content that is to be generated.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.&lt;br /&gt;
&lt;br /&gt;
==onContentBeforeDisplay==&lt;br /&gt;
===Description===&lt;br /&gt;
This is a request for information that should be placed immediately before the generated content. For views that generate HTML, this might include the use of styles that are specified as part of the content or related parameters. Although parameters are passed by reference, this is not the event to modify article data. Use onContentPrepare for that purpose.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
See the onContentPrepare event for additional discussion of these parameters. Note that unlike onContentPrepare, these parameters are passed by value.&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;amp;article&amp;lt;/code&amp;gt; The article that is being rendered by the view.&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;amp;params&amp;lt;/code&amp;gt; An associative array of relevant parameters.&lt;br /&gt;
*&amp;lt;code&amp;gt;limitstart&amp;lt;/code&amp;gt; An integer that determines the &amp;quot;page&amp;quot; of the content that is to be generated.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
*&amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/staging/plugins/content/vote/vote.php#L17 plugins/content/vote/vote.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==onContentAfterDisplay==&lt;br /&gt;
===Description===&lt;br /&gt;
This is a request for information that should be placed immediately after the generated content. For views that generate HTML, this might include the closure of styles that are specified as part of the content or related parameters. Although parameters are passed by reference, this is not the event to modify article data. Use onContentPrepare for that purpose.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
See the onContentPrepare event for additional discussion of these parameters. Note that unlike onContentPrepare, these parameters are passed by value.&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;amp;article&amp;lt;/code&amp;gt; The article that is being rendered by the view.&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;amp;params&amp;lt;/code&amp;gt; A JRegistry object of merged article and menu item params.&lt;br /&gt;
*&amp;lt;code&amp;gt;limitstart&amp;lt;/code&amp;gt; An integer that determines the &amp;quot;page&amp;quot; of the content that is to be generated.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.&lt;br /&gt;
&lt;br /&gt;
==onContentBeforeSave==&lt;br /&gt;
===Description===&lt;br /&gt;
This is an event that is called right before the content is saved into the database. You can abort the save by returning false. In the case of &amp;lt;code&amp;gt;JModelLegacy&amp;lt;/code&amp;gt; for example the error will then be set by calling &amp;lt;code&amp;gt;$this-&amp;gt;setError($table-&amp;gt;getError);&amp;lt;/code&amp;gt; to be displayed to user.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;article&amp;lt;/code&amp;gt; A reference to the JTableContent object that is being saved which holds the article data.&lt;br /&gt;
*&amp;lt;code&amp;gt;isNew&amp;lt;/code&amp;gt; A boolean which is set to true if the content is about to be created.&lt;br /&gt;
*&amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; The data to save. Note this data should be already validated by the extension. Since {{JVer|3.7}}. Required to be set by extensions as of {{JVer|4.0}} as the core joomla content plugin uses this property&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
Boolean. Result will affect the saving process. See description for details.&lt;br /&gt;
&lt;br /&gt;
==onContentAfterSave==&lt;br /&gt;
===Description===&lt;br /&gt;
This is an event that is called after the content is saved into the database. Even though article object is passed by reference, changes will not be saved since storing data into database phase is past. An example use case would be redirecting user to the appropriate place after saving.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;article&amp;lt;/code&amp;gt; A reference to the JTableContent object that is being saved which holds the article data.&lt;br /&gt;
*&amp;lt;code&amp;gt;isNew&amp;lt;/code&amp;gt; A boolean which is set to true if the content is about to be created.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
None. Result will be omitted.&lt;br /&gt;
&lt;br /&gt;
==onContentPrepareForm==&lt;br /&gt;
===Description===&lt;br /&gt;
Called before a JForm is rendered. It can be used to modify the JForm object in memory before rendering. For example, use JForm-&amp;gt;loadFile() to add fields or JForm-&amp;gt;removeField() to remove fields. Or use JForm-&amp;gt;setFieldAttribute() or other JForm methods to modify fields for the form.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
*&amp;lt;code&amp;gt;form&amp;lt;/code&amp;gt; The JForm object to be displayed. Use the $form-&amp;gt;getName() method to check whether this is the form you want to work with.&lt;br /&gt;
*&amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; An object containing the data for the form.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
*&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; True if method succeeds.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
*[https://github.com/joomla/joomla-cms/blob/staging/plugins/user/profile/profile.php#L234 plugins/user/profile/profile.php]&lt;br /&gt;
&lt;br /&gt;
==onContentPrepareData==&lt;br /&gt;
===Description===&lt;br /&gt;
Called after the data for a JForm has been retrieved. It can be used to modify the data for a JForm object in memory before rendering. This is usually used in tandem with the onContentPrepareForm method - this event adds the data to the already altered JForm.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; An object containing the data for the form.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
*&amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; True if method succeeds.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
*[https://github.com/joomla/joomla-cms/blob/staging/plugins/user/profile/profile.php#L68 plugins/user/profile/profile.php]&lt;br /&gt;
&lt;br /&gt;
==onContentBeforeDelete==&lt;br /&gt;
===Description===&lt;br /&gt;
This is an event that is called right before the content is deleted from the database. You can abort the delete by returning false. In the case of &amp;lt;code&amp;gt;JModelLegacy&amp;lt;/code&amp;gt; for example the error will then be set by calling &amp;lt;code&amp;gt;$this-&amp;gt;setError($table-&amp;gt;getError);&amp;lt;/code&amp;gt; to be displayed to user.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt; A reference to the JTableContent object that is being deleted which holds the article data.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
Boolean. Result will affect the saving process. See description for details.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
*[https://www.github.com/joomla/joomla-cms/tree/master/plugins/content/joomla/joomla.php#L89 plugins/content/joomla/joomla.php]&lt;br /&gt;
&lt;br /&gt;
==onContentAfterDelete==&lt;br /&gt;
===Description===&lt;br /&gt;
This is an event that is called after the content is deleted from the database. An example use case would be redirecting user to the appropriate place after deleting.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;article&amp;lt;/code&amp;gt; A reference to the JTableContent object that has been deleted which holds the article data.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
None. Result will be omitted.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
[https://www.github.com/joomla/joomla-cms/tree/master/plugins/content/finder/finder.php#L61 content/finder/finder.php]&lt;br /&gt;
&lt;br /&gt;
==onContentChangeState==&lt;br /&gt;
===Description===&lt;br /&gt;
This is an event that is called after content has its state change (e.g. Published to Unpublished).&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
*&amp;lt;code&amp;gt;context&amp;lt;/code&amp;gt; The context of the content being passed to the plugin - this is the component name and view - or name of module  (e.g. com_content.article). Use this to check whether you are in the desired context for the plugin.&lt;br /&gt;
*&amp;lt;code&amp;gt;$pks&amp;lt;/code&amp;gt; An array of primary key ids of the content that has changed state.&lt;br /&gt;
*&amp;lt;code&amp;gt;$value&amp;lt;/code&amp;gt; The value of the state that the content has been changed to.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
None. Result will be omitted.&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
[https://www.github.com/joomla/joomla-cms/tree/master/plugins/content/finder/finder.php#L80 content/finder/finder.php]&lt;br /&gt;
&lt;br /&gt;
==onContentSearch==&lt;br /&gt;
===Description===&lt;br /&gt;
&lt;br /&gt;
This event is triggered by a variety of search related operations. It is a request for a&lt;br /&gt;
plugin to return the result of a search request. The rows must return the following fields, which are used in a common display routine:&lt;br /&gt;
&lt;br /&gt;
* browsernav&lt;br /&gt;
* catslug&lt;br /&gt;
* created&lt;br /&gt;
* href&lt;br /&gt;
* section&lt;br /&gt;
* slug&lt;br /&gt;
* text&lt;br /&gt;
* title&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;$text&amp;lt;/code&amp;gt; The target search string.&lt;br /&gt;
* &amp;lt;code&amp;gt;$phrase&amp;lt;/code&amp;gt; A string matching option (exact|any|all). Default is &amp;quot;any&amp;quot;.&lt;br /&gt;
* &amp;lt;code&amp;gt;$ordering&amp;lt;/code&amp;gt; A string ordering option (newest|oldest|popular|alpha|category). Default is &amp;quot;newest&amp;quot;.&lt;br /&gt;
* &amp;lt;code&amp;gt;$areas&amp;lt;/code&amp;gt; An array if restricted to areas, null if search all.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
&lt;br /&gt;
Array of stdClass objects with members as described above.&lt;br /&gt;
&lt;br /&gt;
===Used in files===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/master/administrator/components/com_search/models/searches.php#L158 administrator/components/com_search/models/searches.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/master/components/com_search/models/search.php#L154 components/com_search/models/search.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/master/plugins/search/categories/categories.php#L62 plugins/search/categories/categories.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/master/plugins/search/contacts/contacts.php#L60 plugins/search/contacts/contacts.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/master/plugins/search/content/content.php#L53 plugins/search/content/content.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/master/plugins/search/newsfeeds/newsfeeds.php#L60 plugins/search/newsfeeds/newsfeeds.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/master/plugins/search/tags/tags.php#L60 plugins/search/tags/tags.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[https://github.com/joomla/joomla-cms/blob/master/plugins/search/weblinks/weblinks.php#L62 plugins/search/weblinks/weblinks.php]&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==onContentSearchAreas==&lt;br /&gt;
===Description===&lt;br /&gt;
&lt;br /&gt;
This appears to be a request for plugins to identify which &amp;quot;areas&amp;quot; they provide&lt;br /&gt;
search facilities for.&lt;br /&gt;
&lt;br /&gt;
===Parameters===&lt;br /&gt;
&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
===Return Value===&lt;br /&gt;
&lt;br /&gt;
An associative array of area names, indexed by the area identifier. For example, array( &#039;categories&#039; =&amp;gt; &#039;Categories&#039; ).&lt;br /&gt;
&lt;br /&gt;
===Used in files===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;components/com_search/models/search.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;plugins/search/categories.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;plugins/search/contacts.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;plugins/search/content.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;plugins/search/newsfeeds.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;plugins/search/tags/tags.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;plugins/search/weblinks.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Plugin Development]][[Category:Specifications]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User_Group_List_form_field_type&amp;diff=1030168</id>
		<title>User Group List form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User_Group_List_form_field_type&amp;diff=1030168"/>
		<updated>2024-07-16T15:49:24Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/usergrouplist Joomla Manual Usergrouplist Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;usergrouplist&#039;&#039;&#039; form field type provides a dropdown select box of user groups.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;usergrouplist&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the &#039;&#039;value_field&#039;&#039; attribute.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;layout&#039;&#039;&#039; (optional) (translatable) is the layout, for example joomla.form.field.list-fancy-select.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;checksuperusergroup&#039;&#039;&#039; (optional) is boolean to omit Super User groups. Values 1 or 0.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the usergroup id of the default selection in the dropdown list. &amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;multiple&#039;&#039;&#039; (optional) If set to &#039;&#039;true&#039;&#039; then allows more than one usergroup to be selected.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
Implemented by:&amp;lt;/translate&amp;gt; &amp;lt;tt&amp;gt;libraries/src/Form/Field/UsergrouplistField.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Example of usergrouplist form field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;field&lt;br /&gt;
		name=&amp;quot;usergroup&amp;quot;&lt;br /&gt;
		type=&amp;quot;UserGroupList&amp;quot;&lt;br /&gt;
		label=&amp;quot;MOD_EXAMPLE_USERGROUP_LABEL&amp;quot;&lt;br /&gt;
		description=&amp;quot;MOD_EXAMPLE_USERGROUP_DESC&amp;quot;&lt;br /&gt;
		layout=&amp;quot;joomla.form.field.list-fancy-select&amp;quot;&lt;br /&gt;
		checksuperusergroup=&amp;quot;1&amp;quot;&lt;br /&gt;
		default=&amp;quot;&amp;quot;&lt;br /&gt;
		multiple=&amp;quot;0&amp;quot;&lt;br /&gt;
		&amp;gt;&lt;br /&gt;
		&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;MOD_EXAMPLE_SELECT&amp;lt;/option&amp;gt;&lt;br /&gt;
	&amp;lt;/field&amp;gt;				 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:12--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Usergroup_form_field_type&amp;diff=1030167</id>
		<title>Usergroup form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Usergroup_form_field_type&amp;diff=1030167"/>
		<updated>2024-07-16T15:48:05Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|Since Joomla 4 this field is no longer available. Please see [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/usergrouplist Joomla Manual Usergrouplist Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;usergroup&#039;&#039;&#039; form field type provides a dropdown select box of user groups.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;usergroup&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the &#039;&#039;value_field&#039;&#039; attribute.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) is a CSS class name for the HTML form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039; (optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;multiple&#039;&#039;&#039; (optional) If set to &#039;&#039;multiple&#039;&#039; then allows more than one usergroup to be selected.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Implemented by:&amp;lt;/translate&amp;gt; &amp;lt;tt&amp;gt;libraries/joomla/form/fields/usergroup.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
Example usergroup form field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;guest_usergroup&amp;quot; type=&amp;quot;usergroup&amp;quot;&lt;br /&gt;
	label=&amp;quot;COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_LABEL&amp;quot;&lt;br /&gt;
	description=&amp;quot;COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_DESC&amp;quot; &lt;br /&gt;
	multiple=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:11--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=User_form_field_type&amp;diff=1030166</id>
		<title>User form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=User_form_field_type&amp;diff=1030166"/>
		<updated>2024-07-16T15:44:54Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/user Joomla Manual User Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;user&#039;&#039;&#039; form field type provides a modal select box of users.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;user&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the &#039;&#039;value_field&#039;&#039; attribute&amp;lt;/translate&amp;gt;.&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) is a CSS class name for the HTML form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039; (optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Implemented by:&amp;lt;/translate&amp;gt; &amp;lt;tt&amp;gt;libraries/cms/form/field/user.php&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Example user form field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;modified_user_id&amp;quot; type=&amp;quot;user&amp;quot;&lt;br /&gt;
	label=&amp;quot;JGLOBAL_FIELD_MODIFIED_BY_LABEL&amp;quot;&lt;br /&gt;
	class=&amp;quot;readonly&amp;quot;&lt;br /&gt;
	readonly=&amp;quot;true&amp;quot;&lt;br /&gt;
	filter=&amp;quot;unset&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== Note! === &amp;lt;!--T:13--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt; The &#039;&#039;&#039;user&#039;&#039;&#039; field only works on administration forms and should not be added to front-end forms.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:10--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=URL_form_field_type&amp;diff=1030165</id>
		<title>URL form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=URL_form_field_type&amp;diff=1030165"/>
		<updated>2024-07-16T15:43:43Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/url Joomla Manual URL Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
This field essentially is a [[S:MyLanguage/Text_form_field_type|text field]] with the type of url. If a fully qualified url (that is one with a scheme and domain such as &amp;lt;tt&amp;gt;&amp;lt;nowiki&amp;gt;http://example.com&amp;lt;/nowiki&amp;gt;&amp;lt;/tt&amp;gt;) is entered and it uses idn (that is uses characters that are non ascii such as ê or Ψ) it will translate the url into punycode prior to saving.  This ensures that the url will work as intended regardless of environment. If you want to render field data in idn you should wrap it with the conversion method :&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JStringPunycode::urlToUTF8($this-&amp;gt;contact-&amp;gt;webpage)&lt;br /&gt;
&amp;lt;/source&amp;gt;.&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;url&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039; (optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;maxlength&#039;&#039;&#039; (optional) limits the number of characters that may be entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) (not translatable) is the default value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) is a CSS class name for the HTML form field. If omitted this will default to &#039;text_area&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;readonly&#039;&#039;&#039; (optional) The field cannot be changed and will automatically inherit the default value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;disabled&#039;&#039;&#039; (optional) The field cannot be changed and will automatically inherit the default value - it will also not submit.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) The field must be filled before submitting the form.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;filter&#039;&#039;&#039; (optional) allow the system to save certain html tags or raw data.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;validate&#039;&#039;&#039; (optional) makes a validation&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt; &#039;&#039;&#039;relative&#039;&#039;&#039; (optional) set to true for relative URLs&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt; &#039;&#039;&#039;hint&#039;&#039;&#039; (optional) The text displayed in the html placeholder element, usually a lighter coloured hint displayed inside a blank field&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mytextvalue&amp;quot; type=&amp;quot;url&amp;quot; default=&amp;quot;http://www.example.com&amp;quot; label=&amp;quot;Enter a URL&amp;quot; description=&amp;quot;&amp;quot; size=&amp;quot;10&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
Both a url rule and a url input filter can assist with this insuring that valid url data are entered into this field field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:16--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Text form field type|Text form field type]]&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Standard form field types{{#translation:}}]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Timezone_form_field_type&amp;diff=1030164</id>
		<title>Timezone form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Timezone_form_field_type&amp;diff=1030164"/>
		<updated>2024-07-16T15:41:23Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/timezone Joomla Manual Timezone Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;timezone&#039;&#039;&#039; form field type provides a drop down list of time zones. If the field has a value saved, this value is displayed when the page is first loaded. If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt; &lt;br /&gt;
[[Image:Params.timezones.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;timezone&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) (translatable) is the default time zone. For example, use &#039;-10&#039; for &#039;(UTC -10:00) Hawaii&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mytimezone&amp;quot; type=&amp;quot;timezone&amp;quot; default=&amp;quot;-10&amp;quot; label=&amp;quot;Select a timezone&amp;quot; description=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:8--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Textarea_form_field_type&amp;diff=1030163</id>
		<title>Textarea form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Textarea_form_field_type&amp;diff=1030163"/>
		<updated>2024-07-16T15:40:06Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/textarea Joomla Manual Textarea Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;textarea&#039;&#039;&#039; form field type provides a text area for entry of multi-line text. If the field has a value saved, this value is displayed when the page is first loaded. If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt;&lt;br /&gt;
[[Image:Params.textarea.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;textarea&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;rows&#039;&#039;&#039; (mandatory) is the height of the visible text area in lines. If omitted the height is determined by the browser. The value of rows does not limit the number of lines that may be entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;cols&#039;&#039;&#039; (mandatory) is the width of the visible text area in characters. If omitted the width is determined by the browser. The value of cols does not limit the number of characters that may be entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) (not translatable) is the default value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional)  is a CSS class name for the HTML form field. If omitted this will default to &#039;text_area&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;filter&#039;&#039;&#039; (optional) allow the system to save certain html tags or raw data.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;hint&#039;&#039;&#039; (optional) The text displayed in the html placeholder element, usually a lighter coloured hint displayed inside an blank field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt; &lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mytextarea&amp;quot; type=&amp;quot;textarea&amp;quot; default=&amp;quot;default&amp;quot; label=&amp;quot;Enter some text&amp;quot; description=&amp;quot;&amp;quot; rows=&amp;quot;10&amp;quot; cols=&amp;quot;5&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
Use the raw filter to ensure that html code is preserved when the form is processed:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mytextarea&amp;quot; type=&amp;quot;textarea&amp;quot; default=&amp;quot;default&amp;quot; label=&amp;quot;Enter some html&amp;quot; description=&amp;quot;&amp;quot; rows=&amp;quot;10&amp;quot; cols=&amp;quot;5&amp;quot; filter=&amp;quot;raw&amp;quot;/&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;=== Tips === &amp;lt;!--T:13--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
* If you need to line break just encode &amp;lt;code&amp;gt;&amp;amp;lt;br /&amp;amp;gt;&amp;lt;/code&amp;gt; in the XML config file like this:&amp;lt;/translate&amp;gt; &amp;lt;code&amp;gt;&amp;amp;amp;lt;br /&amp;amp;amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
* If you need a new line character in your default value, add &amp;lt;code&amp;gt;&amp;amp;amp;#13;&amp;amp;amp;#10;&amp;lt;/code&amp;gt; to the default parameter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:16--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Text form field type|Text form field type]]&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Text_form_field_type&amp;diff=1030162</id>
		<title>Text form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Text_form_field_type&amp;diff=1030162"/>
		<updated>2024-07-16T15:38:48Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/text Joomla Manual Text Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;text&#039;&#039;&#039; form field type provides a text box for data entry. If the field has a value saved, this value is displayed when the page is first loaded. If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt; &lt;br /&gt;
[[Image:Params.text.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;text&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039; (optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;maxlength&#039;&#039;&#039; (optional) limits the number of characters that may be entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) (not translatable) is the default value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) is a CSS class name for the HTML form field. If omitted this will default to &#039;text_area&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;readonly&#039;&#039;&#039; (optional) The field cannot be changed and will automatically inherit the default value. (Possible values: &amp;quot;true&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;readonly&amp;quot; to set to true)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;disabled&#039;&#039;&#039; (optional) The field cannot be changed and will automatically inherit the default value - it will also not submit. (Possible values: &amp;quot;true&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;readonly&amp;quot; to set to true)&amp;lt;/translate&amp;gt; &lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) The field must be filled before submitting the form. (Possible values: &amp;quot;true&amp;quot;, &amp;quot;1&amp;quot;, &amp;quot;readonly&amp;quot; to set to true)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;filter&#039;&#039;&#039; (optional) allow the system to save certain html tags or raw data.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;message&#039;&#039;&#039; (optional) The error message that will be displayed instead of the default message.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;hint&#039;&#039;&#039; (optional) The text displayed in the html placeholder element, usually a lighter coloured hint displayed inside an blank field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &amp;lt;translate&amp;gt;&amp;lt;!--T:22--&amp;gt; &#039;&#039;&#039;inputtype&#039;&#039;&#039; (optional) Set the HTML5 input type&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt; &#039;&#039;&#039;pattern&#039;&#039;&#039; (optional) A regular expression pattern to use for validation.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &amp;lt;translate&amp;gt;&amp;lt;!--T:24--&amp;gt; &#039;&#039;&#039;charcounter&#039;&#039;&#039; (optional) (Joomla 4.3) Whether to show a character counter (&#039;&#039;true&#039;&#039; or &#039;&#039;false&#039;&#039;). Use in conjunction with &#039;&#039;&#039;maxlength&#039;&#039;&#039;. Default: &#039;&#039;false&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Text field can also take an array of option sub elements in order to show suggestions to user in the text field.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mytextvalue&amp;quot; type=&amp;quot;text&amp;quot; default=&amp;quot;Some text&amp;quot; label=&amp;quot;Enter some text&amp;quot; description=&amp;quot;&amp;quot; size=&amp;quot;10&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
Use the integer filter to ensure that letters types get stripped when the form is processed.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;myintvalue&amp;quot; type=&amp;quot;text&amp;quot; default=&amp;quot;8&amp;quot; label=&amp;quot;Enter some text&amp;quot; description=&amp;quot;Enter some description&amp;quot; filter=&amp;quot;integer&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
Use the raw filter to ensure that html code is preserved when the form is processed.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;myhtmlvalue&amp;quot; type=&amp;quot;text&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Enter some text&amp;quot; description=&amp;quot;Enter some description&amp;quot; filter=&amp;quot;raw&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:18--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Textarea form field type|Textarea form field type]]&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Templatestyle_form_field_type&amp;diff=1030161</id>
		<title>Templatestyle form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Templatestyle_form_field_type&amp;diff=1030161"/>
		<updated>2024-07-16T15:37:41Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/templatestyle Joomla Manual Templatestyle Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Provides a dropdown list of style options.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;templatestyle&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;client&#039;&#039;&#039; (optional) administrator, defaults to site.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; description text for the form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) for styling.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;multiple&#039;&#039;&#039; &amp;lt;translate&amp;gt;(optional) is whether multiple items can be selected at the same time (&#039;&#039;true&#039;&#039; or &#039;&#039;false&#039;&#039;). In Joomla 4 it is recommended to use additionally &amp;lt;code&amp;gt;layout=&amp;quot;joomla.form.field.groupedlist-fancy-select&amp;quot;&amp;lt;/code&amp;gt; in the field declaration (= &amp;lt;code&amp;gt;chosen&amp;lt;/code&amp;gt; replacement).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Example XML Definition :&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;admin_style&amp;quot; type=&amp;quot;templatestyle&amp;quot;&lt;br /&gt;
	client=&amp;quot;administrator&amp;quot;&lt;br /&gt;
	description=&amp;quot;COM_ADMIN_USER_FIELD_BACKEND_TEMPLATE_DESC&amp;quot;&lt;br /&gt;
	label=&amp;quot;COM_ADMIN_USER_FIELD_BACKEND_TEMPLATE_LABEL&amp;quot; &amp;gt;&lt;br /&gt;
		&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;JOPTION_USE_DEFAULT&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Tel_form_field_type&amp;diff=1030160</id>
		<title>Tel form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Tel_form_field_type&amp;diff=1030160"/>
		<updated>2024-07-16T15:36:29Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|Since Joomla 4 this field is not supported. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/telephone Joomla Manual Telephone Field] instead}}&lt;br /&gt;
&lt;br /&gt;
The tel field type is an alias for a [[Text_form_field_type | text field]]. &lt;br /&gt;
&lt;br /&gt;
Telephone numbers can be validated using the tel rule and filtered using the tel input filter.&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Tag_form_field_type&amp;diff=1030159</id>
		<title>Tag form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Tag_form_field_type&amp;diff=1030159"/>
		<updated>2024-07-16T15:34:23Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/tag Joomla Manual Tag Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;Tag&#039;&#039;&#039; field type provides a point where you can enter tags - this is either AJAX or nested.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;tag&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;mode&#039;&#039;&#039; (optional) (translatable) is the description of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is the description of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;id&#039;&#039;&#039; (optional) is the id to add to the field. Note if none is set this will be the name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) is the class to add to the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;published&#039;&#039;&#039; (optional) determines if non published tags should be allowed.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;language&#039;&#039;&#039; (optional) is language to filter the existing tags by.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;multiple&#039;&#039;&#039; (optional) is the ability to add more than 1 tag to the form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;custom&#039;&#039;&#039; (optional) if the ajax mode is chosen setting this to &#039;&#039;deny&#039;&#039; will prevent users from adding in new tags.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
Example XML Definition for an AJAX Tag&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;tags&amp;quot; type=&amp;quot;tag&amp;quot; label=&amp;quot;JTAG&amp;quot; description=&amp;quot;JTAG_DESC&amp;quot; mode=&amp;quot;ajax&amp;quot; class=&amp;quot;inputbox span12 small&amp;quot; multiple=&amp;quot;true&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Example XML Definition for an Nested Tag&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;tags&amp;quot; type=&amp;quot;tag&amp;quot; label=&amp;quot;JTAG&amp;quot; description=&amp;quot;JTAG_DESC&amp;quot; mode=&amp;quot;nested&amp;quot; class=&amp;quot;inputbox span12 small&amp;quot; multiple=&amp;quot;true&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:15--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
[http://magazine.joomla.org/issues/issue-apr-2103/item/1225-joomla-tag-field &amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
Joomla! Community Magazine April 2013 Issue&amp;lt;/translate&amp;gt;]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Subform_form_field_type&amp;diff=1030158</id>
		<title>Subform form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Subform_form_field_type&amp;diff=1030158"/>
		<updated>2024-07-16T15:32:42Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/subform Joomla Manual Subform Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;subform&#039;&#039;&#039; form field type provides a method for using XML forms inside one another or reuse forms inside an existing  form.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
If attribute &#039;&#039;&#039;multiple&#039;&#039;&#039; is set to &#039;&#039;&#039;true&#039;&#039;&#039; then the included form will be &#039;&#039;&#039;repeatable&#039;&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
The Field has two &amp;quot;predefined&amp;quot; layouts for displaying the subform as either a &#039;&#039;&#039;table&#039;&#039;&#039; or as a &#039;&#039;&#039;div&#039;&#039;&#039; container, as well as support for custom layouts.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
An example XML &#039;&#039;&#039;field&#039;&#039;&#039; definition for &#039;&#039;&#039;single&#039;&#039;&#039; mode:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;field-name&amp;quot; type=&amp;quot;subform&amp;quot;&lt;br /&gt;
    formsource=&amp;quot;path/to/exampleform.xml&amp;quot;&lt;br /&gt;
    label=&amp;quot;Subform Field&amp;quot; description=&amp;quot;Subform Field Description&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
An example XML &#039;&#039;&#039;field&#039;&#039;&#039; definition for &#039;&#039;&#039;multiple&#039;&#039;&#039; mode:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;field-name&amp;quot; type=&amp;quot;subform&amp;quot;&lt;br /&gt;
    formsource=&amp;quot;path/to/exampleform.xml&amp;quot; multiple=&amp;quot;true&amp;quot;&lt;br /&gt;
    label=&amp;quot;Subform Field&amp;quot; description=&amp;quot;Subform Field Description&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
Example XML of &#039;&#039;exampleform.xml&#039;&#039;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form&amp;gt;&lt;br /&gt;
    &amp;lt;field name=&amp;quot;example_text&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Example Text&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;field name=&amp;quot;example_textarea&amp;quot; type=&amp;quot;textarea&amp;quot; label=&amp;quot;Example Textarea&amp;quot; cols=&amp;quot;40&amp;quot; rows=&amp;quot;8&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
An example XML of &#039;&#039;exampleform.xml&#039;&#039; with &#039;&#039;fieldsets&#039;&#039;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;form&amp;gt;&lt;br /&gt;
    &amp;lt;fieldset name=&amp;quot;section1&amp;quot; label=&amp;quot;Section1&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;example_text&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Example Text&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;example_textarea&amp;quot; type=&amp;quot;textarea&amp;quot; label=&amp;quot;Example Textarea&amp;quot; cols=&amp;quot;40&amp;quot; rows=&amp;quot;8&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
    &amp;lt;fieldset name=&amp;quot;section2&amp;quot; label=&amp;quot;Section2&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;example_list&amp;quot; type=&amp;quot;list&amp;quot; default=&amp;quot;1&amp;quot; class=&amp;quot;advancedSelect&amp;quot; label=&amp;quot;Example List&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
            &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
        &amp;lt;/field&amp;gt;&lt;br /&gt;
    &amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:44--&amp;gt; The subform XML may also be specified inline as an alternative to placing the subform XML in a separate file.  The following example illustrates this:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
	name=&amp;quot;field-name&amp;quot;&lt;br /&gt;
	type=&amp;quot;subform&amp;quot;&lt;br /&gt;
	label=&amp;quot;Subform Field&amp;quot;&lt;br /&gt;
	description=&amp;quot;Subform Field Description&amp;quot;&lt;br /&gt;
	multiple=&amp;quot;true&amp;quot;&lt;br /&gt;
	min=&amp;quot;1&amp;quot;&lt;br /&gt;
	max=&amp;quot;10&amp;quot;&lt;br /&gt;
	&amp;gt;&lt;br /&gt;
	&amp;lt;form&amp;gt;&lt;br /&gt;
		&amp;lt;field&lt;br /&gt;
			name=&amp;quot;example_text&amp;quot;&lt;br /&gt;
			type=&amp;quot;text&amp;quot;&lt;br /&gt;
			label=&amp;quot;Example Text&amp;quot;&lt;br /&gt;
			/&amp;gt;&lt;br /&gt;
		&amp;lt;field&lt;br /&gt;
			name=&amp;quot;example_textarea&amp;quot;&lt;br /&gt;
			type=&amp;quot;textarea&amp;quot;&lt;br /&gt;
			label=&amp;quot;Example Textarea&amp;quot;&lt;br /&gt;
			cols=&amp;quot;40&amp;quot;&lt;br /&gt;
			rows=&amp;quot;8&amp;quot;&lt;br /&gt;
			/&amp;gt;&lt;br /&gt;
	&amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Field attributes:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;subform&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) The field must be filled before submitting the form.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;message&#039;&#039;&#039; (optional) The error message that will be displayed instead of the default message.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default value, JSON string.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;formsource&#039;&#039;&#039; (mandatory) the form source to be included. A relative path to the xml file (relative to the root folder for the installed Joomla site) or a valid form name which can be found by &#039;&#039;JForm::getInstance()&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;multiple&#039;&#039;&#039; (optional) whether the subform fields are repeatable or not.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;min&#039;&#039;&#039; (optional) count of minimum repeating in multiple mode. Default: &#039;&#039;0&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;max&#039;&#039;&#039; (optional) count of maximum repeating in multiple mode. Default: &#039;&#039;1000&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;groupByFieldset&#039;&#039;&#039; (optional) whether to group the subform fields by its fieldset (&#039;&#039;true&#039;&#039; or &#039;&#039;false&#039;&#039;). Default: &#039;&#039;false&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;buttons&#039;&#039;&#039; (optional) which buttons to show in multiple mode. Default: &#039;&#039;add,remove,move&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;layout&#039;&#039;&#039; (optional) the name of the layout to use when displaying &#039;&#039;&#039;subform&#039;&#039;&#039; fields.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:49--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;validate&#039;&#039;&#039; (optional) should be set to &#039;&#039;Subform&#039;&#039; (note that this is case-sensitive!) to ensure that fields in the subform are individually validated.  Default: Fields in the subform are not validated, even if validation rules are specified.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
Available layouts:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;joomla.form.field.subform.default&#039;&#039;&#039; render the subform in a div container, without support of repeating. Default for single mode.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;joomla.form.field.subform.repeatable&#039;&#039;&#039; render the subform in a div container, used for multiple mode. Support groupByFieldset.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;joomla.form.field.subform.repeatable-table&#039;&#039;&#039; render the subform as a table, used for multiple mode. Supports groupByFieldset. By default each field is rendered as a table column, but if &#039;&#039;groupByFieldset=true&#039;&#039; then each fieldset is rendered as a table column.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Be aware&#039;&#039;&#039;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
If your field in the subform has additional JavaScript logic then it may not work in &#039;&#039;&#039;multiple&#039;&#039;&#039; mode, because do not see the fields which added by the subform field dynamically. If it happened then you need to adjust your field to support it.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:30--&amp;gt;&lt;br /&gt;
Next example may help:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;jQuery(document).ready(function(){&lt;br /&gt;
    ... here the code for setup your field as usual...&lt;br /&gt;
&lt;br /&gt;
    jQuery(document).on(&#039;subform-row-add&#039;, function(event, row){&lt;br /&gt;
        ... here is the code to set up the fields in the new row ...&lt;br /&gt;
    })&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--T:45--&amp;gt;&lt;br /&gt;
Because of this some extra Joomla! fields may not work for now.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Fields Validation and Filters== &amp;lt;!--T:46--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:47--&amp;gt; The subform form field does not provide the Validation and Filters for child fields.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;Addition: Since a security fix in Joomla 3.9.7 the &amp;lt;code&amp;gt;filter=&amp;quot;example&amp;quot;&amp;lt;/code&amp;gt; attributes in subform child fields are supported and the fields will be validated; &#039;&#039;&#039;but NOT&#039;&#039;&#039; in custom form fields that extend the &amp;lt;code&amp;gt;JFormFieldSubform&amp;lt;/code&amp;gt; class. You have to adapt such custom fields yourself!&lt;br /&gt;
===Beware!=== &amp;lt;!--T:48--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;All extensions that use subform fields MUST add an attribute &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; to their subform child fields of type &amp;lt;code&amp;gt;editor&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;textarea&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt; (maybe others, too) since Joomla 3.9.7 like it&#039;s common for &amp;quot;normal&amp;quot; JForm fields, if you want to allow HTML input. Otherwise the validation falls back to STRING, which is the common behavior for &amp;quot;normal&amp;quot; JForm fields.&#039;&#039;&#039;&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
filter=&amp;quot;safehtml&amp;quot;&lt;br /&gt;
filter=&amp;quot;JComponentHelper::filterText&amp;quot;&lt;br /&gt;
filter=&amp;quot;raw&amp;quot; (bad decision in most cases)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example == &amp;lt;!--T:36--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:37--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Problem &#039;&#039;&#039;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:38--&amp;gt;&lt;br /&gt;
After adding new rows selects are not &amp;quot;chosen&amp;quot;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:40--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Solution &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:41--&amp;gt;&lt;br /&gt;
Here is an example how to reinit jQuery Chosen on newly added repeated rows:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;jQuery(document).ready(function(){&lt;br /&gt;
    jQuery(document).on(&#039;subform-row-add&#039;, function(event, row){&lt;br /&gt;
        jQuery(row).find(&#039;select&#039;).chosen();&lt;br /&gt;
    })&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:42--&amp;gt;&lt;br /&gt;
Or a PHP snippet to be used in e.g. your plugin in **onBeforeCompileHead** method or in your component view.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$doc = JFactory::getDocument();&lt;br /&gt;
$js = &#039;&lt;br /&gt;
	jQuery(document).on(\&#039;subform-row-add\&#039;, function(event, row){&lt;br /&gt;
		jQuery(row).find(\&#039;select\&#039;).chosen();&lt;br /&gt;
	})&lt;br /&gt;
&#039;;&lt;br /&gt;
$doc-&amp;gt;addScriptDeclaration($js);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:43--&amp;gt;&lt;br /&gt;
So newly added rows now are &amp;quot;chosen&amp;quot; now &amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Subform data not getting stored to database on custom component.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Solution&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Add the following line to the beginning of your corresponding table class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
protected $_jsonEncode = array(&#039;fieldnamehere&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
More information [https://joomla.stackexchange.com/questions/19163/subform-multiple-data-not-saving Here].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== See also == &amp;lt;!--T:32--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:33--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Standard form field types{{#translation:}}]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=SQL_form_field_type&amp;diff=1030157</id>
		<title>SQL form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=SQL_form_field_type&amp;diff=1030157"/>
		<updated>2024-07-16T15:31:21Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/sql Joomla Manual SQL Field] instead}}&lt;br /&gt;
&lt;br /&gt;
{{Warning|&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Using this generic form field type forces you to write SQL in an XML file and is rather limited. For more flexibility, consider creating your own, specific form field type by subclassing the JFormField class.&amp;lt;/translate&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;sql&#039;&#039;&#039; form field type provides a drop down list of entries obtained by running a query on the Joomla database. If the field has a value saved, this value is selected when the page is first loaded. If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt;&lt;br /&gt;
[[Image:Params.sql.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;sql&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field. This must match the name of the query results column that contains the values that will be shown to the user in the drop-down list, unless a different name is specified in the &#039;&#039;&#039;value_field&#039;&#039;&#039; attribute.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;query&#039;&#039;&#039; (mandatory if not using the sql_* attributes) is the SQL query which will provide the data for the drop-down list. The query must return two columns; one called &#039;&#039;&amp;lt;nowiki&amp;gt;&#039;value&#039;&amp;lt;/nowiki&amp;gt;&#039;&#039; (unless overridden by the &#039;&#039;&#039;key_field&#039;&#039;&#039; attribute) which will hold the values of the list items; the other called the same as the value of the name attribute (unless overridden by the &#039;&#039;&#039;value_field&#039;&#039;&#039; attribute) containing the text to be shown in the drop-down list.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default value. This is the value of the &#039;&#039;&amp;lt;nowiki&amp;gt;&#039;value&#039;&amp;lt;/nowiki&amp;gt;&#039;&#039; column, unless overridden by the &#039;&#039;&#039;key_field&#039;&#039;&#039; attribute.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;multiple&#039;&#039;&#039; (optional) turns the field into a multi-selector. Use multiple=&amp;quot;multiple&amp;quot;.&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;key_field&#039;&#039;&#039; (optional) is the name of the column that will contain values for the parameter. If omitted then the column called &#039;&#039;&amp;lt;nowiki&amp;gt;&#039;value&#039;&amp;lt;/nowiki&amp;gt;&#039;&#039; will be used, if it exists.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;value_field&#039;&#039;&#039; (optional) is the name of the column that will contain values to be shown to the user in the drop-down list. If omitted then the column with the same name as the name attribute will be used, if it exists.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;translate&#039;&#039;&#039; (optional) will translate the output of the &#039;&#039;&#039;value_field&#039;&#039;&#039; if set to true. It defaults to false.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;header&#039;&#039;&#039; (optional) (translatable) will add an entry, with an empty value, at the top of the list of options.  This is usually used to add a &#039;&#039;&amp;quot;- Select something -&amp;quot;&#039;&#039; entry to the list.  See the examples for an alternative way of achieving this.&lt;br /&gt;
* &#039;&#039;&#039;sql_select&#039;&#039;&#039; (mandatory if not using the &#039;&#039;&#039;query&#039;&#039;&#039; attribute) is the SELECT clause of the SQL statement.  Only one such clause is permitted.&lt;br /&gt;
* &#039;&#039;&#039;sql_from&#039;&#039;&#039; (mandatory if not using the &#039;&#039;&#039;query&#039;&#039;&#039; attribute) is the FROM clause of the SQL statement.&lt;br /&gt;
* &#039;&#039;&#039;sql_join&#039;&#039;&#039; (optional) is the LEFT JOIN clause of the SQL statement.  Only one such clause is permitted.&lt;br /&gt;
* &#039;&#039;&#039;sql_where&#039;&#039;&#039; (optional) is the WHERE clause of the SQL statement.  Only one such clause is permitted.&lt;br /&gt;
* &#039;&#039;&#039;sql_group&#039;&#039;&#039; (optional) is the GROUP BY clause of the SQL statement.&lt;br /&gt;
* &#039;&#039;&#039;sql_order&#039;&#039;&#039; (optional) is the ORDER BY clause of the SQL statement.&lt;br /&gt;
* &#039;&#039;&#039;sql_filter&#039;&#039;&#039; (optional) filters the list by the value of another field.  A field name or a comma-separated list of field names can be given.  The field names must correspond to column names in the database table being queried.  See the examples for further explanation.&lt;br /&gt;
* &#039;&#039;&#039;sql_default_{FIELD_NAME}&#039;&#039;&#039; (optional) is the default value used by the &#039;&#039;&#039;sql_filter&#039;&#039;&#039; attribute when the value of the &#039;&#039;{FIELD_NAME}&#039;&#039; filter has not been set.  See the examples for further explanation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
Example XML parameter definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;title&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    default=&amp;quot;10&amp;quot;&lt;br /&gt;
    label=&amp;quot;Select an article&amp;quot;&lt;br /&gt;
    query=&amp;quot;SELECT id AS value, title AS text FROM #__content&amp;quot;&lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
Notice that an AS clause has been used in this example because the &#039;&#039;jos_content&#039;&#039; table does not have a column called &#039;&#039;&amp;lt;nowiki&amp;gt;&#039;value&#039;&amp;lt;/nowiki&amp;gt;&#039;&#039;.  In fact very few tables in the Joomla database have a column called &#039;&#039;&amp;lt;nowiki&amp;gt;&#039;value&#039;&amp;lt;/nowiki&amp;gt;&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Alternatively, you can use a &#039;&#039;&#039;key_field&#039;&#039;&#039; attribute to define the column to be used instead of &#039;&#039;&amp;lt;nowiki&amp;gt;&#039;value&#039;&amp;lt;/nowiki&amp;gt;&#039;&#039;:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;title&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    default=&amp;quot;10&amp;quot;&lt;br /&gt;
    label=&amp;quot;Select an article&amp;quot;&lt;br /&gt;
    query=&amp;quot;SELECT id, title FROM #__content&amp;quot;&lt;br /&gt;
    key_field=&amp;quot;id&amp;quot;&lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
This will give identical results to the previous example.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
Both column names may need to be aliased.  For example, suppose you want your field to be called &#039;&#039;&amp;lt;nowiki&amp;gt;&#039;myfield&#039;&amp;lt;/nowiki&amp;gt;&#039;&#039; instead of &#039;&#039;&amp;lt;nowiki&amp;gt;&#039;title&#039;&amp;lt;/nowiki&amp;gt;&#039;&#039; in the previous example.  Then you can do this:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;myfield&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    default=&amp;quot;10&amp;quot;&lt;br /&gt;
    label=&amp;quot;Select an article&amp;quot;&lt;br /&gt;
    query=&amp;quot;SELECT id AS value, title AS myfield FROM #__content&amp;quot;&lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
Or alternatively:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;myfield&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    default=&amp;quot;10&amp;quot;&lt;br /&gt;
    label=&amp;quot;Select an article&amp;quot;&lt;br /&gt;
    query=&amp;quot;SELECT id, title FROM #__content&amp;quot;&lt;br /&gt;
    key_field=&amp;quot;id&amp;quot;&lt;br /&gt;
    value_field=&amp;quot;title&amp;quot;&lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
You can also assemble or calculate fields in the SQL statement.  For example, suppose you wanted to append the created date/time of each article to the article title in the list.  Then you could use this SQL statement:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
SELECT id, concat( title, &#039; (&#039;, created, &#039;)&#039;) AS title FROM #__content&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
You can also specify a static option in the XML using &amp;lt;option&amp;gt;&amp;lt;/option&amp;gt; tag. Please look at the following example.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;myfield&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    default=&amp;quot;10&amp;quot;&lt;br /&gt;
    label=&amp;quot;Select an article&amp;quot;&lt;br /&gt;
    query=&amp;quot;SELECT id, title FROM #__content&amp;quot;&lt;br /&gt;
    key_field=&amp;quot;id&amp;quot;&lt;br /&gt;
    value_field=&amp;quot;title&amp;quot;&lt;br /&gt;
    required=&amp;quot;true&amp;quot;&lt;br /&gt;
    &amp;gt;&lt;br /&gt;
    &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;Please select your option&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Alternatively, you can achieve the same result using the &#039;&#039;&#039;header&#039;&#039;&#039; attribute as follows:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;myfield&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    default=&amp;quot;10&amp;quot;&lt;br /&gt;
    label=&amp;quot;Select an article&amp;quot;&lt;br /&gt;
    query=&amp;quot;SELECT id, title FROM #__content&amp;quot;&lt;br /&gt;
    key_field=&amp;quot;id&amp;quot;&lt;br /&gt;
    value_field=&amp;quot;title&amp;quot;&lt;br /&gt;
    required=&amp;quot;true&amp;quot;&lt;br /&gt;
    header=&amp;quot;Please select your option&amp;quot;&lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
==== Alternative query syntax ====&lt;br /&gt;
Starting with Joomla 3.5, an alternative to the &#039;&#039;&#039;query&#039;&#039;&#039; attribute allows some additional features.  These features are not available if the &#039;&#039;&#039;query&#039;&#039;&#039; attribute is present.  For example, this field definition:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;example_group&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    label=&amp;quot;COM_EXAMPLE_GROUP&amp;quot;&lt;br /&gt;
    query=&amp;quot;SELECT e.* FROM #__example AS e GROUP BY name ORDER e.id ASC&amp;quot;&lt;br /&gt;
    key_field=&amp;quot;id&amp;quot;&lt;br /&gt;
    value_field=&amp;quot;name&amp;quot;&lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
can be expressed as:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;example_group&amp;quot; &lt;br /&gt;
    type=&amp;quot;sql&amp;quot; &lt;br /&gt;
    label=&amp;quot;COM_EXAMPLE_GROUP&amp;quot; &lt;br /&gt;
    sql_select=&amp;quot;e.*&amp;quot; &lt;br /&gt;
    sql_from=&amp;quot;#__example AS e&amp;quot; &lt;br /&gt;
    sql_group=&amp;quot;name&amp;quot; &lt;br /&gt;
    sql_order=&amp;quot;e.id ASC&amp;quot; &lt;br /&gt;
    key_field=&amp;quot;id&amp;quot;&lt;br /&gt;
    value_field=&amp;quot;name&amp;quot; &lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
{{warning|&amp;lt;translate&amp;gt;&amp;lt;!--T:25--&amp;gt; The following feature &#039;&#039;linked fields as filters&#039;&#039; is currently not working! See [https://github.com/joomla/joomla-cms/issues/22241 Github issue 22241]&amp;lt;/translate&amp;gt;}}&lt;br /&gt;
One advantage to using this syntax is that it allows the use of linked fields as filters.  For example, suppose you have a form containing two select lists, one called &#039;&#039;groups&#039;&#039; and the other called &#039;&#039;subgroups&#039;&#039;.  The &#039;&#039;groups&#039;&#039; field is straightforward:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;groups&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    label=&amp;quot;COM_EXAMPLE_GROUPS&amp;quot;&lt;br /&gt;
    sql_select=&amp;quot;e.*&amp;quot;&lt;br /&gt;
    sql_from=&amp;quot;#__example_groups AS e&amp;quot;&lt;br /&gt;
    sql_group=&amp;quot;name&amp;quot;&lt;br /&gt;
    sql_order=&amp;quot;e.id ASC&amp;quot;&lt;br /&gt;
    key_field=&amp;quot;id&amp;quot;&lt;br /&gt;
    value_field=&amp;quot;name&amp;quot;&lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
but the &#039;&#039;subgroups&#039;&#039; field includes an &#039;&#039;&#039;sql_filter&#039;&#039;&#039; attribute which refers to the &#039;&#039;groups&#039;&#039; field by name:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;subgroups&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    label=&amp;quot;COM_EXAMPLE_SUBGROUPS&amp;quot;&lt;br /&gt;
    sql_select=&amp;quot;e.*&amp;quot;&lt;br /&gt;
    sql_from=&amp;quot;#__example_subgroups AS e&amp;quot;&lt;br /&gt;
    sql_group=&amp;quot;name&amp;quot;&lt;br /&gt;
    sql_order=&amp;quot;e.id ASC&amp;quot;&lt;br /&gt;
    sql_filter=&amp;quot;groups&amp;quot;&lt;br /&gt;
    key_field=&amp;quot;id&amp;quot;&lt;br /&gt;
    value_field=&amp;quot;name&amp;quot;&lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Then if the &#039;&#039;groups&#039;&#039; field has the value &#039;&#039;99&#039;&#039;, the following SQL statement will be executed for the &#039;&#039;subgroups&#039;&#039; field:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
SELECT e.* FROM jos_example_subgroups AS e WHERE `groups` = 99 GROUP BY `name` ORDER BY e.id ASC&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To filter on multiple fields, you can use a comma-separated list of filter names in the &#039;&#039;&#039;sql_filter&#039;&#039;&#039; clause.  For example, if there is a filter called &#039;&#039;groups&#039;&#039; with the value &#039;&#039;99&#039;&#039; and a filter called &#039;&#039;categories&#039;&#039; with the value &#039;&#039;12&#039;&#039;, then&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
sql_filter=&amp;quot;groups,categories&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will produce the SQL WHERE clause:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
WHERE `groups` = 99 AND `categories` = 12&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
You can also define a default value for any filter that might not have a value when the field is evaluated by adding &#039;&#039;&#039;sql_default_{FIELD_NAME}&#039;&#039;&#039; attributes.  For example, suppose that the default value for the &#039;&#039;groups&#039;&#039; filter is 0 and the default value for the &#039;&#039;categories&#039;&#039; filter is 0, then this definition:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;subgroups&amp;quot;&lt;br /&gt;
    type=&amp;quot;sql&amp;quot;&lt;br /&gt;
    label=&amp;quot;COM_EXAMPLE_SUBGROUPS&amp;quot;&lt;br /&gt;
    sql_select=&amp;quot;e.*&amp;quot;&lt;br /&gt;
    sql_from=&amp;quot;#__example_subgroups AS e&amp;quot;&lt;br /&gt;
    sql_group=&amp;quot;name&amp;quot;&lt;br /&gt;
    sql_order=&amp;quot;e.id ASC&amp;quot;&lt;br /&gt;
    sql_filter=&amp;quot;groups,categories&amp;quot;&lt;br /&gt;
    sql_default_groups=&amp;quot;0&amp;quot;&lt;br /&gt;
    sql_default_categories=&amp;quot;1&amp;quot;&lt;br /&gt;
    key_field=&amp;quot;id&amp;quot;&lt;br /&gt;
    value_field=&amp;quot;name&amp;quot;&lt;br /&gt;
    /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will produce this SQL statement when initially evaluated with no filters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
SELECT e.* FROM jos_example_subgroups AS e WHERE `groups` = 0 AND `categories` = 1 GROUP BY `name` ORDER BY e.id ASC&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
Note: The SQL statements will need to be correct for the type and version of the underlying database that Joomla is running on. This will most likely be a version of MySQL, but it could be something else.  There is no capability to query databases other than the one Joomla itself is running on.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
Note: As shown in these examples, the database prefix (often &amp;lt;code&amp;gt;jos&amp;lt;/code&amp;gt;) should be entered in the form &amp;lt;code&amp;gt;#__&amp;lt;/code&amp;gt; (hash-underscore-underscore). It will automatically be replaced by the actual database prefix used by Joomla.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== See also === &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Spacer_form_field_type&amp;diff=1030156</id>
		<title>Spacer form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Spacer_form_field_type&amp;diff=1030156"/>
		<updated>2024-07-16T15:29:14Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/spacer Joomla Manual Spacer Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;spacer&#039;&#039;&#039; form field type provides a visual separator between parameter field elements. It is purely a visual aid and no field value is stored.&amp;lt;/translate&amp;gt;&lt;br /&gt;
[[Image:Params.spacer.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;spacer&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (optional) (translatable) is the text to use as a spacer.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;hr&#039;&#039;&#039; (optional) is whether to display a horizontal rule (&#039;true&#039; or &#039;false&#039;). If this attribute is &#039;true&#039;, the &#039;&#039;&#039;label&#039;&#039;&#039; attribute will be ignored.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) is a CSS class name for the HTML form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field type=&amp;quot;spacer&amp;quot; name=&amp;quot;myspacer&amp;quot; hr=&amp;quot;true&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
You can replace the basic horizontal line with a title which can be used to group parameters. For example,&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field type=&amp;quot;spacer&amp;quot; name=&amp;quot;myspacer&amp;quot; label=&amp;quot;Advanced parameters&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
You can also place translatable text into the label attribute:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field type=&amp;quot;spacer&amp;quot; name=&amp;quot;myspacer&amp;quot; class=&amp;quot;text&amp;quot;&lt;br /&gt;
label=&amp;quot;PLG_TINY_FIELD_NAME_EXTENDED_LABEL&amp;quot;&lt;br /&gt;
/&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
Note that you can also include HTML markup but it must be encoded.  For example, to put the text into bold you can use:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field type=&amp;quot;spacer&amp;quot; name=&amp;quot;myspacer&amp;quot; label=&amp;quot;&amp;amp;lt;b&amp;amp;gt;Advanced parameters&amp;amp;lt;/b&amp;amp;gt;&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;You cannot combine the hr and label attributes.&#039;&#039;&#039; To define a spacer with both a horizontal rule and a label, use an encoded &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;hr/&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; in the &#039;&#039;&#039;label&#039;&#039;&#039; attribute:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field type=&amp;quot;spacer&amp;quot; name=&amp;quot;myspacer&amp;quot; label=&amp;quot;&amp;amp;lt;hr/&amp;amp;gt;More parameters&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== See also === &amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Sessionhandler_form_field_type&amp;diff=1030155</id>
		<title>Sessionhandler form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Sessionhandler_form_field_type&amp;diff=1030155"/>
		<updated>2024-07-16T15:27:55Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/sessionhandler Joomla Manual Sessionhandler Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Provides a dropdown list of session handler options.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;sessionhandler&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; description text for the form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) provides a default value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) &amp;quot;true&amp;quot; to enforce a value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;filter&#039;&#039;&#039; (optional) cleans the input.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Example XML Definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;session_handler&amp;quot; type=&amp;quot;sessionhandler&amp;quot;&lt;br /&gt;
	default=&amp;quot;none&amp;quot;&lt;br /&gt;
	label=&amp;quot;COM_CONFIG_FIELD_SESSION_HANDLER_LABEL&amp;quot;&lt;br /&gt;
	description=&amp;quot;COM_CONFIG_FIELD_SESSION_HANDLER_DESC&amp;quot;&lt;br /&gt;
	required=&amp;quot;true&amp;quot;&lt;br /&gt;
	filter=&amp;quot;word&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Rules_form_field_type&amp;diff=1030154</id>
		<title>Rules form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Rules_form_field_type&amp;diff=1030154"/>
		<updated>2024-07-16T15:26:28Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/rules Joomla Manual Rules Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;rules&#039;&#039;&#039; parameter type provides a matrix of group by action options for managing access control.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;rules&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;component&#039;&#039;&#039; (mandatory) indicates the component to which the action options will apply.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;section&#039;&#039;&#039; (mandatory) indicates the section of the access.xml actions the control should apply to. For example, &amp;quot;component&amp;quot; or &amp;quot;my_item_type&amp;quot;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== See also === &amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|Table of all standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Repeatable_form_field_type&amp;diff=1030153</id>
		<title>Repeatable form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Repeatable_form_field_type&amp;diff=1030153"/>
		<updated>2024-07-16T15:25:06Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|Since Joomla 4 this field is no longer available. Please use the [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/subform Subform Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{tip|&amp;lt;translate&amp;gt;&amp;lt;!--T:28--&amp;gt;&lt;br /&gt;
Please use the [[S:MyLanguage/Subform form field type|Subform form field type]] (in multiple mode) instead.&amp;lt;/translate&amp;gt;|title=&amp;lt;translate&amp;gt;&amp;lt;!--T:29--&amp;gt;&lt;br /&gt;
This field is &#039;&#039;&#039;deprecated&#039;&#039;&#039;&amp;lt;/translate&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Provides a modal with rows of formfields that you specify. As many options can be added as desired. Note this form field has a jQuery based javascript file as a dependency.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;repeatable&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; description text for the form field. Displays at the top of the modal with the name as well as in the usual position in the form.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; The default value for the form field if the field is left empty. Note this has to be a json string compatible with the contents of the form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;id&#039;&#039;&#039; id of the hidden form field. (the modal will have this id with an added suffix of &amp;quot;_modal&amp;quot; and the table within the modal will have this id with a suffix of &amp;quot;_modal_table&amp;quot;).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; class of the table.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;select&#039;&#039;&#039; (translatable) The text to show on the modal button.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;icon&#039;&#039;&#039; the icon to show on the select button (is prefixed with &amp;quot;icon-&amp;quot;).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;maximum&#039;&#039;&#039; the maximum number of rows of fields allowed (by default 999 to be effectively infinite).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
To create a form field you must first of all create a repeatable form field as usual.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;fields&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
Within this you place open and close tag (if not already in one - if there is an existing fields tag for params etc. this is not needed.) and within this a tag.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;fieldset&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
The fieldset tag MUST have a name the same as your repeatable field name with &amp;quot;_modal&amp;quot; appended to the end of it - it should also have the in the fieldset tag.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
repeat=&amp;quot;true&amp;quot;&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
Within this fieldset you then include the form fields that you wish to have repeating (as with any form field).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
Example XML Definition&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;list_templates&amp;quot;&lt;br /&gt;
	type=&amp;quot;repeatable&amp;quot;&lt;br /&gt;
	icon=&amp;quot;list&amp;quot;&lt;br /&gt;
	description=&amp;quot;PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_DESC&amp;quot;&lt;br /&gt;
	label=&amp;quot;PLG_TINY_FIELD_TEMPLATE_FIELD_ELEMENTS_LABEL&amp;quot;&lt;br /&gt;
	default=&#039;{&amp;quot;template&amp;quot;:[&amp;quot;Layout&amp;quot;,&amp;quot;Simple snippet&amp;quot;],&lt;br /&gt;
		&amp;quot;location&amp;quot;:[&amp;quot;layout1.html&amp;quot;,&amp;quot;snippet1.html&amp;quot;],&lt;br /&gt;
		&amp;quot;description&amp;quot;:[&amp;quot;HTMLLayout&amp;quot;,&amp;quot;Simple HTML snippet&amp;quot;]}&#039;&amp;gt;&lt;br /&gt;
	&amp;lt;fieldset hidden=&amp;quot;true&amp;quot; name=&amp;quot;list_templates_modal&amp;quot; repeat=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
		&amp;lt;field name=&amp;quot;template&amp;quot;&lt;br /&gt;
			label=&amp;quot;PLG_TINY_FIELD_TEMPLATE_FIELD_NAME_LABEL&amp;quot;&lt;br /&gt;
			size=&amp;quot;30&amp;quot;&lt;br /&gt;
			type=&amp;quot;text&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;field name=&amp;quot;location&amp;quot;&lt;br /&gt;
			label=&amp;quot;PLG_TINY_FIELD_TEMPLATE_FIELD_LOCATION_LABEL&amp;quot;&lt;br /&gt;
			description=&amp;quot;PLG_TINY_FIELD_TEMPLATE_LOCATION_DESC&amp;quot;&lt;br /&gt;
			size=&amp;quot;30&amp;quot;&lt;br /&gt;
			type=&amp;quot;filelist&amp;quot;&lt;br /&gt;
			directory=&amp;quot;media/editors/tinymce/templates&amp;quot;&lt;br /&gt;
			exclude=&amp;quot;index.html&amp;quot;&lt;br /&gt;
			hide_default=&amp;quot;true&amp;quot;&lt;br /&gt;
			hide_none=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;
		&amp;lt;field name=&amp;quot;description&amp;quot;&lt;br /&gt;
			label=&amp;quot;PLG_TINY_FIELD_TEMPLATE_FIELD_DESCRIPTION_LABEL&amp;quot;&lt;br /&gt;
			size=&amp;quot;30&amp;quot;&lt;br /&gt;
			type=&amp;quot;textarea&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;/fieldset&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
===Considerations for the default value === &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt;&lt;br /&gt;
* The default may contain spaces tabs and new lines &amp;lt;ref&amp;gt;https://tools.ietf.org/html/rfc7158&amp;lt;/ref&amp;gt; (makes for better readability)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:24--&amp;gt;&lt;br /&gt;
* The data elements within the string must be quoted using &amp;quot; instead of &#039;. Failure to do so will cause the json decode to fail on the default values.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
===Retrieving your data=== &amp;lt;!--T:25--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:26--&amp;gt;&lt;br /&gt;
The settings of a repeatable form field are returned as a json encoded array (same as the default)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// get the repeatable field value and decode it&lt;br /&gt;
$list_hosts 	 = json_decode( $params-&amp;gt;get(&#039;list_templates&#039;),true);&lt;br /&gt;
// loop your result&lt;br /&gt;
foreach( $list_templates as $list_templates_idx =&amp;gt; $list_template ) {&lt;br /&gt;
   // do something clever for each of the templates&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References=== &amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Range_form_field_type&amp;diff=1030152</id>
		<title>Range form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Range_form_field_type&amp;diff=1030152"/>
		<updated>2024-07-16T15:22:33Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/range Joomla Manual Range Field] instead}}&lt;br /&gt;
&lt;br /&gt;
The ‘&#039;&#039;range&#039;&#039;&#039; form field type provides a horizontal slider for numeric input. While the default value can be set, there is no indication of the actual value being chosen, just the position of the slider’s thumb. Available from {{JVer|3.2}} &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;range&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (optional) (translatable) is the descriptive title of the field, and will appear in the pop-up when hovering over label as well.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the label.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) (translatable) is the initial default value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) is a CSS class name for the HTML form field.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;min&#039;&#039;&#039; (optional)  this value is the lowest that can be chosen.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;max&#039;&#039;&#039; (optional) this value is the highest that can be chosen.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;step&#039;&#039;&#039; (optional) if user click up/down arrow current value will change by this attribute (this attribute value will be added or subtracted to current field value).&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) should the user be required to enter data in this field?&lt;br /&gt;
&lt;br /&gt;
Example XML field definition which would create a slider having the initial value of 0, with possibility to choose values between -0.5 and 0.5. The slider’s value changes by 0.1 as the slider is moved left or right.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;myrange&amp;quot; type=&amp;quot;range&amp;quot; default=&amp;quot;0&amp;quot; label=&amp;quot;Range from -0.5 to 0.5 step 0.1&amp;quot; description=&amp;quot;&amp;quot; min=&amp;quot;-0.5&amp;quot; max=&amp;quot;0.5&amp;quot; step=&amp;quot;0.1&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== See also === &lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Radio_form_field_type&amp;diff=1030151</id>
		<title>Radio form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Radio_form_field_type&amp;diff=1030151"/>
		<updated>2024-07-16T15:21:00Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/radio Joomla Manual Radio Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;radio&#039;&#039; form field type provides radio buttons to select options. If the field has a saved value, this is selected when the page is first loaded. If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt;&lt;br /&gt;
[[Image:Params.radio.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;radio&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default radio button item value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) New in Joomla 3, if set to class=&amp;quot;btn-group btn-group-yesno&amp;quot; will show coloured buttons&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
The XML &#039;&#039;&amp;lt;field&amp;gt;&#039;&#039; element must include one or more &#039;&#039;&amp;lt;option&amp;gt;&#039;&#039; elements which define the individual radio button items. The text between the &#039;&#039;&amp;lt;option&amp;gt;&#039;&#039; and &#039;&#039;&amp;lt;/option&amp;gt;&#039;&#039; tags is shown as the label for the radio button and is a translatable string. The &#039;&#039;&amp;lt;option&amp;gt;&#039;&#039; tag takes the following argument:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (mandatory) is the value that will be saved for the parameter if this item is selected.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
Tip: Don&#039;t forget to close the field definition with &#039;&#039;&amp;lt;/field&amp;gt;&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;myradiovalue&amp;quot; type=&amp;quot;radio&amp;quot; default=&amp;quot;0&amp;quot; label=&amp;quot;Select an option&amp;quot; description=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
For Joomla 3+ styling with arbitrary values:&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;myradiovalue&amp;quot; type=&amp;quot;radio&amp;quot; default=&amp;quot;0&amp;quot; label=&amp;quot;Select an option&amp;quot; description=&amp;quot;&amp;quot; class=&amp;quot;btn-group&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
For Joomla 3+ styling with yes/no values:&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;myradiovalue&amp;quot; type=&amp;quot;radio&amp;quot; default=&amp;quot;0&amp;quot; label=&amp;quot;Select an option&amp;quot; description=&amp;quot;&amp;quot; class=&amp;quot;btn-group btn-group-yesno&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;JYES&amp;lt;/option&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== See Also == &amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/List form field type|List form field type]]&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Predefined_List_form_field_type&amp;diff=1030150</id>
		<title>Predefined List form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Predefined_List_form_field_type&amp;diff=1030150"/>
		<updated>2024-07-15T21:33:08Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/predefinedlist Joomla Manual PredefinedList Field] instead}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;PredefinedList&#039;&#039;&#039; form field type provides a drop down list of pre-defined entries. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected.&lt;br /&gt;
&lt;br /&gt;
Largely the configuration options are the same as that of the list field however the values for the field are created by the &amp;lt;source lang=&amp;quot;php&amp;quot; inline&amp;gt;predefinedOptions&amp;lt;/source&amp;gt; class variable. So the following variables have the same meaning as the list field:&lt;br /&gt;
&lt;br /&gt;
[[Image:Params.list.jpg|right]]&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;PredefinedList&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default list item value.&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional)  is a CSS class name for the HTML form field. If omitted this will default to &#039;inputbox&#039;.&lt;br /&gt;
* &#039;&#039;&#039;multiple&#039;&#039;&#039; (optional) is whether multiple items can be selected at the same time (&#039;&#039;true&#039;&#039; or &#039;&#039;false&#039;&#039;).&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) if set to true, the first field option should be empty, see last example.&lt;br /&gt;
* &#039;&#039;&#039;useglobal&#039;&#039;&#039; (optional) if set to true, it will show the value that is set in the global configuration if found in the database.&lt;br /&gt;
&lt;br /&gt;
Example XML field definition:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mylistvalue&amp;quot; type=&amp;quot;Myextension.Mycustompredefinedlist&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Select an option&amp;quot; description=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
this would be accompanied by your field defined in PHP which would look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
class MyextensionFormFieldMycustompredefinedlist extends JFormFieldPredefinedList&lt;br /&gt;
{&lt;br /&gt;
	public $type = &#039;Mycustompredefinedlist&#039;;&lt;br /&gt;
&lt;br /&gt;
	protected $predefinedOptions = array(&lt;br /&gt;
		&#039;1&#039;  =&amp;gt; &#039;COM_FOO_LABEL_FOR_TRANSLATION&#039;,&lt;br /&gt;
		&#039;0&#039;  =&amp;gt; &#039;COM_FOO_ANOTHER_LABEL_FOR_TRANSLATION&#039;,&lt;br /&gt;
	);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additionally in PHP you can set the `translate` class variable to false which will cause the values of your predefined option to not pass through JText for translation before being shown to the user.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Standard form field types{{#translation:}}]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Plugins_form_field_type&amp;diff=1030149</id>
		<title>Plugins form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Plugins_form_field_type&amp;diff=1030149"/>
		<updated>2024-07-15T21:29:35Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/plugins Joomla Manual Plugins Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Provides a dropdown list of plugin options from the folder.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;plugins&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;folder&#039;&#039;&#039; (mandatory) &#039;&#039;editors&#039;&#039; or &#039;&#039;captcha&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; description text for the form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
Example XML Definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;editor&amp;quot; type=&amp;quot;plugins&amp;quot; folder=&amp;quot;editors&amp;quot;&lt;br /&gt;
	description=&amp;quot;COM_USERS_USER_FIELD_EDITOR_DESC&amp;quot;&lt;br /&gt;
	label=&amp;quot;COM_USERS_USER_FIELD_EDITOR_LABEL&amp;quot; &amp;gt;&lt;br /&gt;
	&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;JOPTION_USE_DEFAULT&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;captcha&amp;quot; type=&amp;quot;plugins&amp;quot; folder=&amp;quot;captcha&amp;quot;&lt;br /&gt;
	label=&amp;quot;COM_CONTACT_FIELD_CAPTCHA_LABEL&amp;quot;&lt;br /&gt;
	description=&amp;quot;COM_CONTACT_FIELD_CAPTCHA_DESC&amp;quot;&lt;br /&gt;
	default=&amp;quot;&amp;quot; &lt;br /&gt;
	filter=&amp;quot;cmd&amp;quot; &amp;gt;&lt;br /&gt;
	&amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;JOPTION_USE_DEFAULT&amp;lt;/option&amp;gt;&lt;br /&gt;
	&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JOPTION_DO_NOT_USE&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Password_form_field_type&amp;diff=1030148</id>
		<title>Password form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Password_form_field_type&amp;diff=1030148"/>
		<updated>2024-07-15T21:28:17Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/password Joomla Manual Password Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;password&#039;&#039;&#039; form field type provides a text box for entry of a password. The password characters will be obscured as they are entered. If the field has a saved value this is entered (in obscured form) into the text box. If not, the default value (if any) is entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
[[Image:Params.password.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
Note that the password string is stored in &#039;&#039;params.ini&#039;&#039; in cleartext; the stored value is not obscured by any hash function.  Since most web servers will, by default, serve a &#039;&#039;params.ini&#039;&#039; file if the URL is entered in a web browser, this cannot be considered a secure method of holding a password.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;password&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039; (optional) is the width of the text box in characters. If omitted the width is determined by the browser. The value of size does not limit the number of characters that may be entered.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default password.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional)  is a CSS class name for the HTML form field. If omitted this will default to &#039;text_area&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;lock&#039;&#039;&#039; (optional)  is a boolean value, if active it removes the password from the output and adds a &#039;&#039;Modify&#039;&#039; button to the password field. It only transmits data if the fields is in &#039;&#039;modify&#039;&#039; mode.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mypassword&amp;quot; type=&amp;quot;password&amp;quot; default=&amp;quot;secret&amp;quot; label=&amp;quot;Enter a password&amp;quot; description=&amp;quot;&amp;quot; size=&amp;quot;5&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== See also === &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Text form field type|Text form field type]]&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Number_form_field_type&amp;diff=1030147</id>
		<title>Number form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Number_form_field_type&amp;diff=1030147"/>
		<updated>2024-07-15T21:21:51Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/number Joomla Manual Number Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;number&#039;&#039;&#039; form field type provides a HTML5 text box with arrows. If the field has a value saved, this value is displayed when the page is first loaded. If not, the default value (if any) is used. Available from {{JVer|3.2}}&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;number&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (optional) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) (translatable) is the default value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) is a CSS class name for the HTML form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;min&#039;&#039;&#039; (optional)  this value is the lowest that can be chosen.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;max&#039;&#039;&#039; (optional) this value is the highest that can be chosen.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;step&#039;&#039;&#039; (optional) if user click up/down arrow current value will change by this attribute (this attribute value will be added or subtracted to current field value).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;filter&#039;&#039;&#039; (optional) the filter to be used on this field value after submit.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;hint&#039;&#039;&#039; (optional) placeholder to be set on this field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;disabled&#039;&#039;&#039; (optional) should this field be disabled?&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;readonly&#039;&#039;&#039; (optional) should this field be read only?&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) should this field be required?&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;autocomplete&#039;&#039;&#039; (optional) should this field use auto complete?&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;autofocus&#039;&#039;&#039; (optional) should this field have focus when page first time loads?&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039; (optional) the maximum field width in characters.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
Example XML field definition which would create a number box with possibility to chose values between 0 and 10 and change current value by 1 each time user click up/down field button.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mynumbervalue&amp;quot; type=&amp;quot;number&amp;quot; default=&amp;quot;0&amp;quot; label=&amp;quot;Choose an number&amp;quot; description=&amp;quot;&amp;quot; min=&amp;quot;0&amp;quot; max=&amp;quot;10&amp;quot; step=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== See also === &amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Note_form_field_type&amp;diff=1030146</id>
		<title>Note form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Note_form_field_type&amp;diff=1030146"/>
		<updated>2024-07-15T21:20:43Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/note Joomla Manual Note Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
This form field makes it possible to create titles, texts, descriptions and even alert boxes. It also allows you to bring order in the settings for extensions, by separating them with useful titles. Or adding descriptions for certain settings (without having to rely on the tooltips). Or adding any other text you want.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
The syntax is straight-forward:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;...&amp;quot; type=&amp;quot;note&amp;quot; label=&amp;quot;...&amp;quot; description=&amp;quot;...&amp;quot; class=&amp;quot;...&amp;quot; close=&amp;quot;...&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Attributes== &amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
*&#039;&#039;Name:&#039;&#039; contains the name of the field (as with any other field tag)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
*&#039;&#039;Type:&#039;&#039; the type of the field, which is: note&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
*&#039;&#039;Label:&#039;&#039; the title of the note (uses JText) (optional if using description)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
*&#039;&#039;Description:&#039;&#039; the description/text of the note (uses JText) (optional if using label)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
*&#039;&#039;Heading:&#039;&#039; the type of heading element to use for the label (optional) (default: h4)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
*&#039;&#039;Class:&#039;&#039; a class name (or class names), like alert (see below for examples) (optional)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
*&#039;&#039;Close:&#039;&#039; a value of &#039;true&#039; (for alerts) or the value for the data-dismiss of the Bootstrap close icon (optional)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Title and Description== &amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
In the following code examples we will use these example language strings:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
LOREMIPSUM=&amp;quot;Lorem ipsum dolor sit amet&amp;quot;&lt;br /&gt;
LOREMIPSUM_DESC=&amp;quot;Consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
With this note field you can either use the title or the description or both.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt10&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;note11&amp;quot; type=&amp;quot;note&amp;quot; label=&amp;quot;LOREMIPSUM&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt11&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;note12&amp;quot; type=&amp;quot;note&amp;quot; description=&amp;quot;LOREMIPSUM_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt12&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;note13&amp;quot; type=&amp;quot;note&amp;quot; label=&amp;quot;LOREMIPSUM&amp;quot; description=&amp;quot;LOREMIPSUM_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt13&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Help25-note-form-field-title-screenshot.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Classes (Alerts)== &amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
You can add classes to the note. In this way you can easily make (Bootstrap) alerts and also add other styling via class names (like a &#039;well&#039;).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt20&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;note21&amp;quot; type=&amp;quot;note&amp;quot; class=&amp;quot;alert&amp;quot; label=&amp;quot;LOREMIPSUM&amp;quot; description=&amp;quot;LOREMIPSUM_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt21&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;note22&amp;quot; type=&amp;quot;note&amp;quot; class=&amp;quot;alert alert-info&amp;quot; label=&amp;quot;LOREMIPSUM&amp;quot; description=&amp;quot;LOREMIPSUM_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt22&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;note23&amp;quot; type=&amp;quot;note&amp;quot; class=&amp;quot;alert alert-success&amp;quot; label=&amp;quot;LOREMIPSUM&amp;quot; description=&amp;quot;LOREMIPSUM_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt23&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;note24&amp;quot; type=&amp;quot;note&amp;quot; class=&amp;quot;alert alert-error&amp;quot; label=&amp;quot;LOREMIPSUM&amp;quot; description=&amp;quot;LOREMIPSUM_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt24&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Help25-note-form-field-classes-screenshot.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
==Close Button== &amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
A close button can be added to the alerts by adding the &#039;&#039;close=&amp;quot;true&amp;quot;&#039;&#039; attribute to the tag. If you use a class other than the alert, use the required value for the data-dismiss of the Bootstrap close icon instead of the value &#039;&#039;true&#039;&#039;. Here is the code to test the close icon on an alert.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt30&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;note31&amp;quot; type=&amp;quot;note&amp;quot; class=&amp;quot;alert&amp;quot; close=&amp;quot;true&amp;quot; label=&amp;quot;LOREMIPSUM&amp;quot; description=&amp;quot;LOREMIPSUM_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;opt31&amp;quot; type=&amp;quot;text&amp;quot; label=&amp;quot;Some Other Option&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:Help25-note-form-field-close-screenshot.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:21--&amp;gt;&lt;br /&gt;
Be aware that a closed alert/note cannot be reopened by the user without page reload. It&#039;s not a show/hide functionality.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also == &amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=ModuleTag_form_field_type&amp;diff=1030145</id>
		<title>ModuleTag form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=ModuleTag_form_field_type&amp;diff=1030145"/>
		<updated>2024-07-15T21:19:04Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/moduletag Joomla Manual ModuleTag Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Provides a list of html5 elements (used to wrap a module in).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;moduletag&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Example XML Definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;module_tag&amp;quot; type=&amp;quot;moduletag&amp;quot;&lt;br /&gt;
	label=&amp;quot;COM_MODULES_FIELD_MODULE_TAG_LABEL&amp;quot;&lt;br /&gt;
	description=&amp;quot;COM_MODULES_FIELD_MODULE_TAG_DESC&amp;quot;&lt;br /&gt;
	default=&amp;quot;div&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;	&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=ModulePosition_form_field_type&amp;diff=1030144</id>
		<title>ModulePosition form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=ModulePosition_form_field_type&amp;diff=1030144"/>
		<updated>2024-07-15T21:17:52Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/moduleposition Joomla Manual ModulePosition Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Provides a text input and button to set the position of a module.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; &amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
(mandatory) must be &#039;&#039;moduleposition&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; &amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
(mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; &amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
(mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; &amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
(optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Example XML Definition&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;position&amp;quot; type=&amp;quot;moduleposition&amp;quot;	&lt;br /&gt;
	description=&amp;quot;COM_MODULES_FIELD_POSITION_DESC&amp;quot;&lt;br /&gt;
	label=&amp;quot;COM_MODULES_FIELD_POSITION_LABEL&amp;quot;&lt;br /&gt;
	default=&amp;quot;&amp;quot;&lt;br /&gt;
	maxlength=&amp;quot;50&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
If adding this field to a fieldset outside of the com_modules scope you will have to include &#039;&#039;&#039;addfieldpath=&amp;quot;administrator/components/com_modules/models/fields&amp;quot;&#039;&#039;&#039; in your &#039;&#039;&#039;&amp;lt;fieldset&amp;gt;&#039;&#039;&#039; tag&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;fieldset name=&amp;quot;fieldsetname&amp;quot; label=&amp;quot;myfield&amp;quot;&lt;br /&gt;
	  addfieldpath=&amp;quot;administrator/components/com_modules/models/fields&amp;quot;&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
If set up properly, you will see a button displayed next to the textbox (with Joomla standard language text that you can set up to say what you wish in your language file) which when clicked, brings up the standard module position selection window you&#039;re used to seeing in the Module Manager.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=ModuleOrder_form_field_type&amp;diff=1030143</id>
		<title>ModuleOrder form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=ModuleOrder_form_field_type&amp;diff=1030143"/>
		<updated>2024-07-15T21:16:31Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/moduleorder Joomla Manual ModuleOrder Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Provides a drop down to set the ordering of module in a given position.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;moduleorder&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) tooltip for the form field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Example XML Definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;ordering&amp;quot; type=&amp;quot;moduleorder&amp;quot;&lt;br /&gt;
	label=&amp;quot;JFIELD_ORDERING_LABEL&amp;quot; &lt;br /&gt;
	description=&amp;quot;JFIELD_ORDERING_DESC&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Modulelayout_form_field_type&amp;diff=1030142</id>
		<title>Modulelayout form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Modulelayout_form_field_type&amp;diff=1030142"/>
		<updated>2024-07-15T21:15:09Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/modulelayout Joomla Manual Modulelayout Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;modulelayout&#039;&#039;&#039; form field type provides a drop down list of all available layouts for a module, grouped by core and template.  If the parameter has a saved value this is selected when the page is first loaded.  If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;modulelayout&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
Combining following attributes enable you to provide a drop down list of layouts of a specific module.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;module&#039;&#039;&#039; (optional) is a specific module name (e.g. &#039;&#039;mod_articles_category&#039;&#039;).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;client_id&#039;&#039;&#039; (optional).&lt;br /&gt;
** If &#039;&#039;0&#039;&#039; (site): Forces searching for layouts only in directories &#039;&#039;/modules/[MODULENAME]/tmpl/&#039;&#039; and all &#039;&#039;/templates/[TEMPLATENAME]/html/[MODULENAME]/&#039;&#039;.&lt;br /&gt;
** If &#039;&#039;1&#039;&#039; (administrator): Forces searching for layouts only in directories &#039;&#039;/administrator/modules/[MODULENAME]/tmpl/&#039;&#039; and all &#039;&#039;/administrator/templates/[TEMPLATENAME]/html/[MODULENAME]/&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;template&#039;&#039;&#039; (optional) is a template name (e.g. &#039;&#039;protostar&#039;&#039; or &#039;&#039;isis&#039;&#039;). If set forces searching for module template overrides only in this template.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Example XML parameter definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mymodulelayout&amp;quot; type=&amp;quot;modulelayout&amp;quot; label=&amp;quot;JFIELD_ALT_LAYOUT_LABEL&amp;quot; description=&amp;quot;JFIELD_ALT_MODULE_LAYOUT_DESC&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== Use Language Constants as Option Values ===&lt;br /&gt;
The layout values can be translated if a language constant has been defined in the correct format in the module or template.&lt;br /&gt;
&lt;br /&gt;
Within the module language file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
MOD_MYMODULE_LAYOUT_LIST=&amp;quot;My Option Label&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The string &amp;quot;My Option Label&amp;quot; is displayed for the file / option &amp;quot;list.php&amp;quot; and not &amp;quot;list&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== See also === &amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Meter_form_field_type&amp;diff=1030141</id>
		<title>Meter form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Meter_form_field_type&amp;diff=1030141"/>
		<updated>2024-07-15T21:13:52Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/meter Joomla Manual Meter Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
Draws a progress bar. (see [http://getbootstrap.com/2.3.2/components.html#progress here] for more details)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the parameter.&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;meter&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) tooltip for the form field.&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional) specify your own classes for additonal markup&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;size&#039;&#039;&#039; (optional) sets the input size of the field&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) the initial value of the progress bar.&lt;br /&gt;
* &#039;&#039;&#039;min&#039;&#039;&#039; (optional) the minimum value of the progress bar.&lt;br /&gt;
* &#039;&#039;&#039;max&#039;&#039;&#039; (optional) the maximum value of the progress bar.&lt;br /&gt;
* &#039;&#039;&#039;step&#039;&#039;&#039; (optional) the step at which the progress changes on the bar.&lt;br /&gt;
* &#039;&#039;&#039;animated&#039;&#039;&#039; (optional)(default:true) sets whether the progress bar is animated or not.&lt;br /&gt;
* &#039;&#039;&#039;active&#039;&#039;&#039; (optional)(default:false) sets whether the progress bar animation is active. Works with &#039;&#039;&#039;animated&#039;&#039;&#039; .&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
Note that without setting the &#039;&#039;&#039;min&#039;&#039;&#039; and &#039;&#039;&#039;max&#039;&#039;&#039; values it will probably not work as expected.&lt;br /&gt;
This is &#039;&#039;&#039;NOT&#039;&#039;&#039; an input type. It just creates a progress bar:&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;field name=&amp;quot;meter&amp;quot;&lt;br /&gt;
               active=&amp;quot;true&amp;quot;&lt;br /&gt;
               type=&amp;quot;meter&amp;quot;&lt;br /&gt;
               label=&amp;quot;Meter&amp;quot;&lt;br /&gt;
               max=&amp;quot;1000&amp;quot;&lt;br /&gt;
               min=&amp;quot;1&amp;quot;&lt;br /&gt;
               step=&amp;quot;10&amp;quot;&lt;br /&gt;
               default=&amp;quot;240&amp;quot;&lt;br /&gt;
               /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
This will create the following HTML code:&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;control-group&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div class=&amp;quot;control-label&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;label id=&amp;quot;jform_meter-lbl&amp;quot; for=&amp;quot;jform_meter&amp;quot; class=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
	Meter&lt;br /&gt;
    &amp;lt;/label&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div class=&amp;quot;controls&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;div class=&amp;quot;progress  progress-striped active&amp;quot; data-max=&amp;quot;1000&amp;quot; data-min=&amp;quot;1&amp;quot; data-step=&amp;quot;10&amp;quot; data-value=&amp;quot;240&amp;quot;&amp;gt;		&lt;br /&gt;
          &amp;lt;div class=&amp;quot;bar&amp;quot; style=&amp;quot;width: 23.923923923924%;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
       &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Menuitem_form_field_type&amp;diff=1030140</id>
		<title>Menuitem form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Menuitem_form_field_type&amp;diff=1030140"/>
		<updated>2024-07-15T21:12:40Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/menuitem Joomla Manual Menuitem Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;menuitem&#039;&#039;&#039; form field type provides a drop down grouped list of the available menu items from your Joomla site.&amp;lt;/translate&amp;gt; &lt;br /&gt;
 [[Image:Params.menuitem.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;menuitem&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default menu item.  Note that this is the ItemID number of the menu item.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;published&#039;&#039;&#039; (optional) determines whether all menu items are listed or only published menu items. If state is &#039;0&#039; then all menu items will be listed.  If state is &#039;1&#039; then only published menu items will be listed. You also can use comma separated values like &#039;1,2&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;menu_type&#039;&#039;&#039; (optional) filters by the &amp;lt;code&amp;gt;menutype&amp;lt;/code&amp;gt; value in database table &amp;lt;code&amp;gt;#__menu&amp;lt;/code&amp;gt; or rather the value of form field &amp;lt;code&amp;gt;Menu Type&amp;lt;/code&amp;gt; in edit form of a menu.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;client_id&#039;&#039;&#039; (optional) filters by the &amp;lt;code&amp;gt;client_id&amp;lt;/code&amp;gt; value in database table &amp;lt;code&amp;gt;#__menu&amp;lt;/code&amp;gt;. &#039;0&#039; for site menu items. &#039;1&#039; for administrator menu items. The default value is &#039;0&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;language&#039;&#039;&#039; (optional) filters by the &amp;lt;code&amp;gt;language&amp;lt;/code&amp;gt; value in database table &amp;lt;code&amp;gt;#__menu&amp;lt;/code&amp;gt; (language tags). You can also use comma separated values like &#039;en-GB,de-DE&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
To add additional rows with translatable strings (such as &amp;quot;Select&amp;quot; or &amp;quot;Default&amp;quot;) add an option to the XML. For example:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option	value=&amp;quot;&amp;quot;&amp;gt;JDEFAULT&amp;lt;/option&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mymenuitem&amp;quot; type=&amp;quot;menuitem&amp;quot; default=&amp;quot;45&amp;quot; label=&amp;quot;Select a menu item&amp;quot; description=&amp;quot;Select a menu item&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== Resolving a URL === &amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
The menuitem form field type gives the ID of the selected menu item. To get a search engine friendly URL using the ID, use JRoute:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;JRoute::_(&amp;quot;index.php?Itemid={$id}&amp;quot;);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
=== See also === &amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Menu form field type|Menu form field type]]&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Menu_form_field_type&amp;diff=1030139</id>
		<title>Menu form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Menu_form_field_type&amp;diff=1030139"/>
		<updated>2024-07-15T21:11:22Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/menu Joomla Manual Menu Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;menu&#039;&#039;&#039; form field type provides a drop down list of the available menus from your Joomla! site. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt; &lt;br /&gt;
[[Image:Params.menu.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
The first option on the list is always &#039;- Select Menu -&#039; (which is a translatable string) and is given the value 0.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;menu&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default menu. Note that this is the name of the menu shown in the Type column on the Menu Manager screen and not the menu ID number.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mymenu&amp;quot; type=&amp;quot;menu&amp;quot; default=&amp;quot;mainmenu&amp;quot; label=&amp;quot;Select a menu&amp;quot; description=&amp;quot;Select a menu&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:9--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Menuitem form field type|Menuitem form field type]]&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Media_form_field_type&amp;diff=1030138</id>
		<title>Media form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Media_form_field_type&amp;diff=1030138"/>
		<updated>2024-07-15T21:10:04Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/media Joomla Manual Media Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;media&#039;&#039;&#039; form field type provides modal access to the media manager for the choice of an image or other kind of media, e.g. video. Users with appropriate permissions will be able to upload files.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;media&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;directory&#039;&#039;&#039; (optional) is the directory from which the user will be able to choose a file. This attribute should be relative to the top level &amp;lt;code&amp;gt;/images/&amp;lt;/code&amp;gt; folder.  The default is that the user will be confined to the top level &amp;lt;code&amp;gt;/images/&amp;lt;/code&amp;gt; folder.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;preview&#039;&#039;&#039; (optional) shows or hides the preview of the currently chosen image. (&amp;quot;true&amp;quot;: Show always, &amp;quot;tooltip&amp;quot;: Show as tooltip, &amp;quot;false&amp;quot;: Show never).  Default is &amp;quot;tooltip&amp;quot;.  (since Joomla! 2.5.5)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;preview_width&#039;&#039;&#039; (optional) sets the max-width of preview image (default: &amp;quot;200&amp;quot;).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;preview_height&#039;&#039;&#039; (optional) sets the max-height of preview image (default: &amp;quot;200&amp;quot;).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;types&#039;&#039;&#039; (optional) is a comma-separated list of file types (&amp;quot;images&amp;quot;, &amp;quot;audios&amp;quot;, &amp;quot;videos&amp;quot; and &amp;quot;documents&amp;quot;). Default is &amp;quot;images&amp;quot;. This list decides which of the allowed file extensions from Media Manager configuration are used. E.g. &amp;quot;images,documents&amp;quot; means only files with an allowed images extension or an allowed documents extension are available for selection.   (since Joomla! 4.0.0)&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:15--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;myimage&amp;quot; type=&amp;quot;media&amp;quot; directory=&amp;quot;stories&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
This will open the media manager with the directory &amp;lt;code&amp;gt;/images/stories/&amp;lt;/code&amp;gt; already selected.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt; Note that if you are using this field on the frontend then permissions restrictions are likely to be in force. If the user is not authorised to view or add media they will see an error page in the modal popup (&amp;quot;403 You are not authorised to view this resource.&amp;quot;).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:10--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/File form field type|File form field type]]&lt;br /&gt;
* [[S:MyLanguage/Imagelist form field type|Imagelist form field type]]&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Standard form field types{{#translation:}}]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=List_form_field_type&amp;diff=1030137</id>
		<title>List form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=List_form_field_type&amp;diff=1030137"/>
		<updated>2024-07-15T21:08:37Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/list Joomla Manual List Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;list&#039;&#039;&#039; form field type provides a drop down list or a list box of custom-defined entries. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt; &lt;br /&gt;
[[Image:Params.list.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;list&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default list item value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional)  is a CSS class name for the HTML form field. If omitted this will default to &#039;inputbox&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;multiple&#039;&#039;&#039; (optional) is whether multiple items can be selected at the same time (&#039;&#039;true&#039;&#039; or &#039;&#039;false&#039;&#039;).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:18--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;required&#039;&#039;&#039; (optional) if set to true, the first field option should be empty, see last example.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:21--&amp;gt; * &#039;&#039;&#039;useglobal&#039;&#039;&#039; (optional) if set to true, it will show the value that is set in the global configuration if found in the database.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
The XML &amp;lt;code&amp;gt;&amp;lt;field&amp;gt;&amp;lt;/code&amp;gt; element must include one or more &amp;lt;code&amp;gt;&amp;lt;option&amp;gt;&amp;lt;/code&amp;gt; elements which define the list items. The text between the &amp;lt;code&amp;gt;&amp;lt;option&amp;gt;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;lt;/option&amp;gt;&amp;lt;/code&amp;gt; tags is what will be shown in the drop down list and is a translatable string. The &amp;lt;code&amp;gt;&amp;lt;option&amp;gt;&amp;lt;/code&amp;gt; tag takes the following argument:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039; (mandatory) is the value that will be saved for the field if this item is selected.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:19--&amp;gt; * &#039;&#039;&#039;requires&#039;&#039;&#039; (optional) Values: multilanguage, associations and adminlanguage can be used.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Tip: Don&#039;t forget to close the field definition with &amp;lt;code&amp;gt;&amp;lt;/field&amp;gt;&amp;lt;/code&amp;gt;.&amp;lt;/translate&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
Tip: Add first an option without a value, with a text like &amp;quot;Select an option&amp;quot;. Otherwise, in case of a required field, the first option with a value gets silently selected (i.e., without the user choosing it). This text will typically be seen by users before clicking the dropdown list.&amp;lt;/translate&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:20--&amp;gt;&lt;br /&gt;
Tip: Some values for &amp;quot;name&amp;quot; field are reserved, so don&#039;t use them and avoid problems. One of them is: &amp;quot;style&amp;quot;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mylistvalue&amp;quot; type=&amp;quot;list&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Select an option&amp;quot; description=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;Option 1&amp;lt;/option&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;Option 2&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
Example XML field definition with required field value:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mylistvalue&amp;quot; type=&amp;quot;list&amp;quot; default=&amp;quot;&amp;quot; required=&amp;quot;true&amp;quot; label=&amp;quot;Select an option&amp;quot; description=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;&amp;quot;&amp;gt;Please Select&amp;lt;/option&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;Option 1&amp;lt;/option&amp;gt;&lt;br /&gt;
  &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;Option 2&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
== Showon attribute for list options == &amp;lt;!--T:22--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:23--&amp;gt; Since Joomla 3.9.0 one can use the &amp;lt;code&amp;gt;showon&amp;lt;/code&amp;gt; attribute for &amp;lt;code&amp;gt;option&amp;lt;/code&amp;gt; tags in a list field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:24--&amp;gt; * See [[S:MyLanguage/Form field#Showon|Showon documentation]].&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:25--&amp;gt; * This feature was introduced with the Pull Request [https://github.com/joomla/joomla-cms/pull/18998 #18998].&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:26--&amp;gt; Example XML for two list fields &amp;lt;code&amp;gt;fielda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;fieldb&amp;lt;/code&amp;gt; where the displayed options of &amp;lt;code&amp;gt;fieldb&amp;lt;/code&amp;gt; are controlled by selections in &amp;lt;code&amp;gt;fielda&amp;lt;/code&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;fielda&amp;quot;&lt;br /&gt;
    type=&amp;quot;list&amp;quot;&lt;br /&gt;
    label=&amp;quot;FIELDA_LABEL&amp;quot;&lt;br /&gt;
    description=&amp;quot;FIELDA_DESC&amp;quot;&lt;br /&gt;
    &amp;gt;&lt;br /&gt;
    &amp;lt;option value=&amp;quot;editor&amp;quot;&amp;gt;TYPE_EDITOR&amp;lt;/option&amp;gt;&lt;br /&gt;
    &amp;lt;option value=&amp;quot;text&amp;quot;&amp;gt;TYPE_TEXT&amp;lt;/option&amp;gt;&lt;br /&gt;
    &amp;lt;option value=&amp;quot;textarea&amp;quot;&amp;gt;TYPE_TEXTAREA&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;field&lt;br /&gt;
    name=&amp;quot;fieldb&amp;quot;&lt;br /&gt;
    type=&amp;quot;list&amp;quot;&lt;br /&gt;
    label=&amp;quot;FIELDB_LABEL&amp;quot;&lt;br /&gt;
    description=&amp;quot;FIELDB_DESC&amp;quot;&lt;br /&gt;
    &amp;gt;&lt;br /&gt;
    &amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;JNO&amp;lt;/option&amp;gt;&lt;br /&gt;
    &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;Option 1&amp;lt;/option&amp;gt;&lt;br /&gt;
    &amp;lt;option&lt;br /&gt;
	    showon=&amp;quot;fielda:text,textarea&amp;quot;&lt;br /&gt;
	    value=&amp;quot;2&amp;quot;&amp;gt;Option 2&amp;lt;/option&amp;gt;&lt;br /&gt;
    &amp;lt;option&lt;br /&gt;
	    showon=&amp;quot;fielda:text&amp;quot;&lt;br /&gt;
	    value=&amp;quot;3&amp;quot;&amp;gt;Option 3&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/field&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:27--&amp;gt;&lt;br /&gt;
* &amp;quot;Option 3&amp;quot; of &amp;lt;code&amp;gt;fieldb&amp;lt;/code&amp;gt; is only displayed if option &amp;quot;TYPE_TEXT&amp;quot; is selected in &amp;lt;code&amp;gt;fielda&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;quot;Option 2&amp;quot; of &amp;lt;code&amp;gt;fieldb&amp;lt;/code&amp;gt; is only displayed if option &amp;quot;TYPE_TEXT&amp;quot; OR &amp;quot;TYPE_TEXTAREA&amp;quot; is selected in &amp;lt;code&amp;gt;fielda&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;quot;Option 1&amp;quot; and &amp;quot;JNO&amp;quot; of &amp;lt;code&amp;gt;fieldb&amp;lt;/code&amp;gt; is always displayed.&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
===See also=== &amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Filelist form field type|Filelist form field type]]&lt;br /&gt;
* [[S:MyLanguage/Folderlist form field type|Folderlist form field type]]&lt;br /&gt;
* [[S:MyLanguage/Imagelist form field type|Imagelist form field type]]&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
[[Category:Standard form field types{{#translation:}}]]&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Language_form_field_type&amp;diff=1030136</id>
		<title>Language form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Language_form_field_type&amp;diff=1030136"/>
		<updated>2024-07-15T21:07:14Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/language Joomla Manual Language Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;languages&#039;&#039;&#039; form field type provides a drop down list of the installed languages for the Frontend or Backend. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected. The value saved is the language tag.  For example, for English (United Kingdom) this will be &#039;&#039;en-GB&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
[[Image:Params.language.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
The first option on the list is always &#039;&#039;- Select Language -&#039;&#039; (which is a translatable string) and is given the value 0.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;language&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;client&#039;&#039;&#039; (mandatory) is the application whose installed languages will be listed. Use &#039;&#039;site&#039;&#039; when you want to list the Frontend languages or &#039;&#039;administrator&#039;&#039; when you want to list the Backend languages.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default language tag. For example, &#039;&#039;en-GB&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
Example XML parameter definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt; lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mylanguage&amp;quot; type=&amp;quot;language&amp;quot; client=&amp;quot;site&amp;quot; default=&amp;quot;en-GB&amp;quot; label=&amp;quot;Select a language&amp;quot; description=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See Also === &amp;lt;!--T:10--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Integer_form_field_type&amp;diff=1030135</id>
		<title>Integer form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Integer_form_field_type&amp;diff=1030135"/>
		<updated>2024-07-15T21:05:42Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/integer Joomla Manual Integer Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;integer&#039;&#039;&#039; form field type provides a select box with a range of integer values. If the field has a value saved, this value is displayed when the page is first loaded. If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;integer&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) (translatable) is the default value.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional)  is a CSS class name for the HTML form field.  If omitted this will default to &#039;text_area&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;first&#039;&#039;&#039; (mandatory) this value is the lowest on the list.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;last&#039;&#039;&#039; (mandatory) this value is the highest on the list.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;step&#039;&#039;&#039; (mandatory) each option will be the previous option incremented by this integer, starting with the &#039;&#039;&#039;first&#039;&#039;&#039; value until the &#039;&#039;&#039;last&#039;&#039;&#039; value is reached.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
Example XML field definition which would create a select box with the choices of 1,2,3,4,5,6,7,8,9,10:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;myintegervalue&amp;quot; type=&amp;quot;integer&amp;quot; default=&amp;quot;Some integer&amp;quot; label=&amp;quot;Choose an integer&amp;quot; description=&amp;quot;&amp;quot; first=&amp;quot;1&amp;quot; last=&amp;quot;10&amp;quot; step=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:12--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Imagelist_form_field_type&amp;diff=1030134</id>
		<title>Imagelist form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Imagelist_form_field_type&amp;diff=1030134"/>
		<updated>2024-07-15T21:04:19Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/imagelist Joomla Manual Imagelist Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;imagelist&#039;&#039;&#039; form field type provides a drop down list of image files in a specified directory. Only files with .png, .gif, .jpg, .bmp, .ico extensions are listed. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected.&amp;lt;/translate&amp;gt; &lt;br /&gt;
[[Image:Params.imagelist.jpg|right]]&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
By default, the first item on the list is &#039;- Do not use -&#039; (which is translatable) and is given the value &#039;-1&#039; and this is followed by &#039;- Use default -&#039; (also translatable) given the value &#039;0&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;imagelist&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;directory&#039;&#039;&#039; (optional) is the filesystem path to the directory containing the image files to be listed. If omitted the directory given by JPATH_ROOT is assumed.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default image file name.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;filter&#039;&#039;&#039; (optional) is a regular expression string which is used to filter the list of image files selected for inclusion in the drop-down list. If omitted, all image files in the directory are included. The filter argument expression is applied before the exclude argument expression. For information on constructing regular expressions see [[S:MyLanguage/Regular expressions in parameter arguments|Regular expressions in parameter arguments]].&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;exclude&#039;&#039;&#039; (optional) is a regular expression string which is used to exclude image files from the list. The exclude argument expression is applied after the filter argument expression. For information on constructing regular expressions see [[S:MyLanguage/Regular expressions in parameter arguments|Regular expressions in parameter arguments]].&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;stripext&#039;&#039;&#039; (optional) is a Boolean argument. If true then file name extensions will be stripped from the image file names listed. Also note that the file name will be saved without the extension too.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:12--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;hide_none&#039;&#039;&#039; (optional) is a Boolean argument. If true, the &#039;- Do not use -&#039; item is omitted from the drop-down list.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:13--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;hide_default&#039;&#039;&#039; (optional) is a Boolean argument. If true, the &#039;- Use default -&#039; item is omitted from the drop-down list.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:14--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;myimage&amp;quot; type=&amp;quot;imagelist&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Select an image&amp;quot; description=&amp;quot;&amp;quot; directory=&amp;quot;&amp;quot; exclude=&amp;quot;&amp;quot; stripext=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:15--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:16--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:17--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&lt;br /&gt;
&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Hidden_form_field_type&amp;diff=1030133</id>
		<title>Hidden form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Hidden_form_field_type&amp;diff=1030133"/>
		<updated>2024-07-15T18:48:11Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: Added deprecation notice and link to Joomla Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|This page has been superseded and is no longer maintained. Please go to [https://manual.joomla.org/docs/general-concepts/forms-fields/standard-fields/hidden Joomla Manual Hidden Field] instead}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;hidden&#039;&#039;&#039; form field type provides a hidden field for saving a field whose value cannot be altered directly by a user in the Administrator (it can be altered in code or by editing the xml file). If the parameter has a saved value this is entered in the text box. If not, the default value (if any) is entered. As the field is hidden there is no visible field in the Administrator.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;hidden&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (mandatory) is the data which needs to be collected.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;class&#039;&#039;&#039; (optional)  is a CSS class name for the HTML form field.  If omitted this will default to &#039;text_area&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
Example XML field definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;mysecretvariable&amp;quot; type=&amp;quot;hidden&amp;quot; default=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:7--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:9--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Helpsite_form_field_type&amp;diff=1030132</id>
		<title>Helpsite form field type</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Helpsite_form_field_type&amp;diff=1030132"/>
		<updated>2024-07-15T18:46:51Z</updated>

		<summary type="html">&lt;p&gt;Robbiej: marked as obsolete&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;noinclude&amp;gt;&amp;lt;languages /&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
{{Warning|Since Joomla 4 the Helpsite Form Field type is no longer available}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:1--&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;helpsite&#039;&#039;&#039; form field type provides a drop down list of the help sites in your Joomla installation. If the field has a saved value this is selected when the page is first loaded. If not, the default value (if any) is selected. With the exception of the “Local” entry, which is always added, the list of help sites is generated from the file:&amp;lt;/translate&amp;gt;&lt;br /&gt;
[[Image:Params.helpsites.jpg|right]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:2--&amp;gt;&lt;br /&gt;
The &#039;local&#039; string is translatable.  The &#039;local&#039; URL returned is an empty string.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:3--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;type&#039;&#039;&#039; (mandatory) must be &#039;&#039;helpsite&#039;&#039;.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:4--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039; (mandatory) is the unique name of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:5--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;label&#039;&#039;&#039; (mandatory) (translatable) is the descriptive title of the field.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:6--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;default&#039;&#039;&#039; (optional) is the default help site URL (not the visible help site name).&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:7--&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;description&#039;&#039;&#039; (optional) (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:8--&amp;gt;&lt;br /&gt;
Example XML parameter definition:&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;field name=&amp;quot;myhelpsite&amp;quot; type=&amp;quot;helpsite&amp;quot; default=&amp;quot;&amp;quot; label=&amp;quot;Select a help site&amp;quot; description=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;translate&amp;gt;=== See also === &amp;lt;!--T:9--&amp;gt;&amp;lt;/translate&amp;gt;&lt;br /&gt;
&amp;lt;translate&amp;gt;&amp;lt;!--T:10--&amp;gt;&lt;br /&gt;
* [[S:MyLanguage/Standard form field types|List of standard form field types]]&amp;lt;/translate&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&amp;lt;translate&amp;gt;&amp;lt;!--T:11--&amp;gt;&lt;br /&gt;
[[Category:Standard form field types]]&amp;lt;/translate&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Robbiej</name></author>
	</entry>
</feed>