<?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=Tonypartridge</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=Tonypartridge"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Tonypartridge"/>
	<updated>2026-10-02T07:41:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Client-side_form_validation&amp;diff=464816</id>
		<title>Client-side form validation</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Client-side_form_validation&amp;diff=464816"/>
		<updated>2017-11-02T14:06:42Z</updated>

		<summary type="html">&lt;p&gt;Tonypartridge: JUtility GetToken was deprecated.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{JSplit}}&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Joomla 1.5 and later versions contain a behavior, which allows your form and its elements to be validated at client side, i.e., before it is submitted to the server. The behavior enables the script &#039;&#039;&#039;validate.js&#039;&#039;&#039; and used [http://mootools.net MooTools] up to version 3.2 and jQuery from version 3.3.&lt;br /&gt;
&lt;br /&gt;
Note: Validate.js is a validation system different from the one provided by [http://mootools.net/docs/more/Forms/Form.Validator MooTools].&lt;br /&gt;
&lt;br /&gt;
==Enable the Validation==&lt;br /&gt;
&lt;br /&gt;
Add a behavior to your form view template. For Joomla versions before 1.5.2:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtmlBehavior::formvalidation();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
For versions from 1.5.2 to 3.3.6:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtml::_(&#039;behavior.formvalidation&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
For versions from 3.4:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtml::_(&#039;behavior.formvalidator&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the form-validate class to your form&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;form class=&amp;quot;form-validate&amp;quot;&amp;gt; ... &amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a validation class to your form field declarations. Joomla adds a &#039;&#039;blur&#039;&#039; handler to validate the form field when the user moves away from the field.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;email&amp;quot; type=&amp;quot;text&amp;quot; class=&amp;quot;required validate-email&amp;quot; size=&amp;quot;30&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//For radios make sure the class is applied to the options: &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;field name=&amp;quot;ThisorThat&amp;quot; type=&amp;quot;radio&amp;quot; label=&amp;quot;Please say if it was full-time or the part-time equivalent?&amp;quot; &amp;gt;&lt;br /&gt;
 &amp;lt;option value=&amp;quot;This&amp;quot; class=&amp;quot;required&amp;quot;&amp;gt;This&amp;lt;/option&amp;gt;&lt;br /&gt;
 &amp;lt;option value=&amp;quot;That&amp;quot; class=&amp;quot;required&amp;quot;&amp;gt;That&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;
For lists which are required the first option should have a value of &amp;quot;&amp;quot; as per:&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;selectme&amp;quot; type=&amp;quot;list&amp;quot; required=&amp;quot;true&amp;quot; label=&amp;quot;Please say if it was full-time or the part-time equivalent?&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;This&amp;quot;&amp;gt;This&amp;lt;/option&amp;gt;&lt;br /&gt;
 &amp;lt;option value=&amp;quot;That&amp;quot;&amp;gt;That&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;
The following classes are available:&lt;br /&gt;
* required&lt;br /&gt;
* validate-username&lt;br /&gt;
* validate-password&lt;br /&gt;
* validate-numeric&lt;br /&gt;
* validate-email&lt;br /&gt;
* validate-[custom] -&amp;gt; custom defined - see below&lt;br /&gt;
&lt;br /&gt;
Note: Joomla 2.5 translates the &#039;&#039;required&#039;&#039; field attribute into a &#039;&#039;required&#039;&#039; class value.&lt;br /&gt;
&lt;br /&gt;
Finally, add the &#039;&#039;validate&#039;&#039; class to your submit button. This will cause an &#039;&#039;onclick&#039;&#039; handler to be added that validates the whole form. The form will only be submitted if it is valid.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;button type=&amp;quot;submit&amp;quot; class=&amp;quot;validate&amp;quot;&amp;gt;Submit form&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Custom Handlers==&lt;br /&gt;
&lt;br /&gt;
If you want a custom handler, you can add one to the class, as in the following example (to be defined AFTER loading validate.js):&lt;br /&gt;
&lt;br /&gt;
MooTools&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
window.addEvent(&#039;domready&#039;, function(){&lt;br /&gt;
   document.formvalidator.setHandler(&#039;birth&#039;, function(value) {&lt;br /&gt;
      regex=/^\d{4}-\d{2}-\d{2}$/;&lt;br /&gt;
      return regex.test(value);&lt;br /&gt;
   });&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
jQuery&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
jQuery(document).ready(function(){&lt;br /&gt;
   document.formvalidator.setHandler(&#039;birth&#039;, function(value) {&lt;br /&gt;
      regex=/^\d{4}-\d{2}-\d{2}$/;&lt;br /&gt;
      return regex.test(value);&lt;br /&gt;
   });&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
You can then assign validate-birth to any field to make it validate as yyyy-mm-dd.  (Valid date is not checked!)&lt;br /&gt;
&lt;br /&gt;
If you want a custom handler to check both the passwords (Password and Confirm Password) are same, please add the following script after the validate.js:&lt;br /&gt;
&lt;br /&gt;
MooTools&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
window.addEvent(&#039;domready&#039;, function(){&lt;br /&gt;
    document.formvalidator.setHandler(&#039;passverify&#039;, function (value) {&lt;br /&gt;
        return ($(&#039;password&#039;).value == value); &lt;br /&gt;
    });&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
jQuery(document).ready(function(){&lt;br /&gt;
    document.formvalidator.setHandler(&#039;passverify&#039;, function (value) {&lt;br /&gt;
        return (jQuery(&#039;input[type=password]&#039;).value == value); &lt;br /&gt;
    });&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Add the class &amp;quot;validate-passverify&amp;quot; to the input field as below:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&amp;lt;input class=&amp;quot;inputbox required validate-passverify&amp;quot; type=&amp;quot;password&amp;quot; id=&amp;quot;password2&amp;quot; name=&amp;quot;password2&amp;quot; size=&amp;quot;40&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Styling/Templating Invalid Elements==&lt;br /&gt;
&lt;br /&gt;
Joomla assigns the &#039;&#039;invalid&#039;&#039; class to form fields that do not pass the validation test. &#039;&#039;invalid&#039;&#039; is also added to the field labels.&lt;br /&gt;
If you style the class in the cascading style sheet, your users will be able to see which fields are wrong. For instance:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
.invalid {&lt;br /&gt;
    border-color: red !important;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Some site templates may already contain such definition. (This one is taken from &#039;&#039;beez_20&#039;&#039;.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Only Accept the Form After Validation==&lt;br /&gt;
     This section is not necessary, if it works at all. See validate class on submit buttons.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem &amp;amp; workaround with JToolBar==&lt;br /&gt;
If you are using JHTML::_(&#039;behavior.formvalidation&#039;) with JToolBar, for example use in backend, the above method will not work. This is because it depends on onSubmit event which did not fire when we call form.submit via JavaScript. To work around this, we have to move the code in onSubmit to be in submitbutton function override. This will look like this:-&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
/* Override joomla.javascript, as form-validation not work with ToolBar */&lt;br /&gt;
function submitbutton(pressbutton) {&lt;br /&gt;
    if (pressbutton == &#039;cancel&#039;) {&lt;br /&gt;
        submitform(pressbutton);&lt;br /&gt;
    }else{&lt;br /&gt;
        var f = document.adminForm;&lt;br /&gt;
        if (document.formvalidator.isValid(f)) {&lt;br /&gt;
            f.check.value=&#039;&amp;lt;?php echo JSession::getFormToken(); ?&amp;gt;&#039;; //send token&lt;br /&gt;
            submitform(pressbutton);    &lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
            var msg = new Array();&lt;br /&gt;
            msg.push(&#039;Invalid input, please verify again!&#039;);&lt;br /&gt;
            if ($(&#039;title&#039;).hasClass(&#039;invalid&#039;)) {&lt;br /&gt;
                msg.push(&#039;&amp;lt;?php echo JText::_(&#039;COM_JONGMAN_ERROR_SCHEDULE_TITLE_IS_REQUIRED&#039;)?&amp;gt;&#039;);    &lt;br /&gt;
            }&lt;br /&gt;
            if($(&#039;admin_email&#039;).hasClass(&#039;invalid&#039;)){&lt;br /&gt;
                msg.push(&#039;&amp;lt;?php echo JText::_(&#039;COM_JONGMAN_ERROR_INVALID_EMAIL&#039;)?&amp;gt;&#039;);&lt;br /&gt;
            }&lt;br /&gt;
            alert (msg.join(&#039;\n&#039;));&lt;br /&gt;
        }&lt;br /&gt;
    }    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==More on mootools validation==&lt;br /&gt;
More available classes on the mootools site here: [http://mootools.net/docs/more/Forms/Form.Validator#Validators http://mootools.net/docs/more/Forms/Form.Validator#Validators]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Server- or Client-side validation?==&lt;br /&gt;
[[Form validation]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Tutorials]][[Category:Development]][[Category:Component Development]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tonypartridge</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=List_form_field_type&amp;diff=452372</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=452372"/>
		<updated>2017-10-09T04:41:55Z</updated>

		<summary type="html">&lt;p&gt;Tonypartridge: Added requires usage to the option field.&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;
&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;
* &#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;
&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;
* &#039;&#039;&#039;requires&#039;&#039;&#039; (optional) Values: multilanguage, associations and adminlanguage can be used..&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;&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;=== See also === &amp;lt;!--T:13--&amp;gt;&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;
* [[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;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:15--&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>Tonypartridge</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=How_to_use_the_filesystem_package&amp;diff=443288</id>
		<title>How to use the filesystem package</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=How_to_use_the_filesystem_package&amp;diff=443288"/>
		<updated>2017-08-23T14:18:03Z</updated>

		<summary type="html">&lt;p&gt;Tonypartridge: Space should follow after //&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{version|1.5,2.5,3.x}}&lt;br /&gt;
=Using the JFILE:: class=&lt;br /&gt;
&lt;br /&gt;
There are 4 classes in the filesystem library.&lt;br /&gt;
&lt;br /&gt;
* JFile:: (file.php)&lt;br /&gt;
* JFolder:: (folder.php)&lt;br /&gt;
* JPath:: (path.php)&lt;br /&gt;
* JArchive:: (archive.php)&lt;br /&gt;
&lt;br /&gt;
This tutorial focuses on the JFile:: class.&lt;br /&gt;
&lt;br /&gt;
The base for filehandling is the JFile class, found in libraries/joomla/filesystem/file.php&lt;br /&gt;
Below you can see the most common options from this library file. At the end of this post you can find a very simple script for file upload.&lt;br /&gt;
&lt;br /&gt;
==Get file extension==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
$ext =  JFile::getExt($filename);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pretty clear, just feed the function with a filename and it will return the extension of the file you selected.&lt;br /&gt;
&lt;br /&gt;
==Strip file extension==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
$name = JFile::stripExt($filename);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This will return the filename without the extension.&lt;br /&gt;
&lt;br /&gt;
==Clean filename==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
$safefilename = JFile::makeSafe($filename);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It cleans out all odd characters from a filename and returns a safe filename.&lt;br /&gt;
&lt;br /&gt;
==Copy a file==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFile::copy($src, $dest);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It is basically a wrapper for the PHP copy() function, but also checks if the file you want to copy exists and the destination really is available. Great thing is that this function also makes use of the FTP-layer in J15 if necessary.&lt;br /&gt;
&lt;br /&gt;
==Delete a file==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFile::delete($path.$file);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It tries to delete the file, making sure it is actually existing, but also checks permissions. If permissions are not set up properly, it tries to change them and delete the file. It also uses the FTP-layer when necessary.&lt;br /&gt;
&lt;br /&gt;
==Upload a file==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFile::upload($src, $dest);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It is basically the wrapper for the PHP move_uploaded_file() function, but also does checks availability and permissions on both source and destination path.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
So how does that look in a script? I put up a small code snippet of an upload script. Some of the functions are used.&lt;br /&gt;
The script is fired from an upload form. That form has a file element, called file_upload (see below).&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
&amp;lt;form name=&amp;quot;upload&amp;quot; method=&amp;quot;post&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;file&amp;quot; name=&amp;quot;file_upload&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;input type=&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;
Note:&lt;br /&gt;
If you didn´t add the part: enctype=&amp;quot;multipart/form-data&amp;quot; then you are unable to upload a file!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Upload code looks like this:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/*&lt;br /&gt;
* File upload example&lt;br /&gt;
*/&lt;br /&gt;
// Retrieve file details from uploaded file, sent from upload form&lt;br /&gt;
$file = JFactory::getApplication()-&amp;gt;input-&amp;gt;get(&#039;file_upload&#039;);&lt;br /&gt;
&lt;br /&gt;
// Import filesystem libraries. Perhaps not necessary, but does not hurt&lt;br /&gt;
jimport(&#039;joomla.filesystem.file&#039;);&lt;br /&gt;
&lt;br /&gt;
// Clean up filename to get rid of strange characters like spaces etc&lt;br /&gt;
$filename = JFile::makeSafe($file[&#039;name&#039;]);&lt;br /&gt;
&lt;br /&gt;
// Set up the source and destination of the file&lt;br /&gt;
$src = $file[&#039;tmp_name&#039;];&lt;br /&gt;
$dest = JPATH_COMPONENT . DS . &amp;quot;uploads&amp;quot; . DS . $filename;&lt;br /&gt;
&lt;br /&gt;
// First check if the file has the right extension, we need jpg only&lt;br /&gt;
if (strtolower(JFile::getExt($filename)) == &#039;jpg&#039;) &lt;br /&gt;
{&lt;br /&gt;
   // TODO: Add security checks&lt;br /&gt;
&lt;br /&gt;
   if (JFile::upload($src, $dest))&lt;br /&gt;
   {&lt;br /&gt;
      // Redirect to a page of your choice&lt;br /&gt;
   } &lt;br /&gt;
   else&lt;br /&gt;
   {&lt;br /&gt;
      // Redirect and throw an error message&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
   // Redirect and notify user file is not right extension&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Using the JFolder:: class=&lt;br /&gt;
The base for folder handling is the JFolder class, found in libraries/joomla/filesystem/folder.php&lt;br /&gt;
Below I will discuss the most common options from this library file. At the end of this post, I put it together in a very simple script as an exmaple&lt;br /&gt;
&lt;br /&gt;
==Copy folder==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::copy($src, $dest, $path, $force);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This will copy a complete folder and all of it’s contents to another location on the server. It does permission and availability checking on both source and destination. By using $path you can enter a basepath to prefix to the filename and by setting the $force parameter to true, you can force the overwriting of already existing files. If set in the configuration, the FTP-layer will be used.&lt;br /&gt;
&lt;br /&gt;
==Create folder==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::create($path, $mode);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This is basically a wrapper for the php mkdir() function, but with error permissions and availability checking. This one also uses the FTP-layer when set in the configuration. $mode will set the default permission, once copied and defaults to 0755.&lt;br /&gt;
&lt;br /&gt;
==Move folder==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::move($src, $dest);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Basically a wrapper for the php rename() function, but with permissions and availability checking. This one also uses the FTP-layer when set in the configuration.&lt;br /&gt;
&lt;br /&gt;
==Check if folder exists==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::exists($path);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Wrapper for the php is_dir() function. Pretty straightforward, returns true if folder exists.&lt;br /&gt;
&lt;br /&gt;
==Read files from folder==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::files($path, $filter = &#039;.&#039;, $recurse, $fullpath , $exclude);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Function to read files from a folder. When setting $recurse to true, also subfolders will be searched. $fullpath set to true returns the full path in the array. With $exclude, you can offer an array of extensions, not to include in the search for files. It returns an array with all filenames.&lt;br /&gt;
&lt;br /&gt;
==Read folders from filesystem==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::folders($path, $filter = &#039;.&#039;, $recurse, $fullpath , $exclude);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Exactly the same as JFolder::files(), except this does only return an array with foldernames.&lt;br /&gt;
&lt;br /&gt;
==Make a tree like list from a folder structure==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::listFolderTree($path, $filter, $maxLevel = 3, $level = 0, $parent = 0);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It will read a folder, specified in $path and will return all folders in an array, suitable for tree display. You can specify the number of levels. The folder array looks like this:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
Array&lt;br /&gt;
(&lt;br /&gt;
    [0] =&amp;gt; Array&lt;br /&gt;
        (&lt;br /&gt;
            [id] =&amp;gt; 1&lt;br /&gt;
            [parent] =&amp;gt; 0&lt;br /&gt;
            [name] =&amp;gt; administrator&lt;br /&gt;
            [fullname] =&amp;gt; g:/joomla_1012/administrator&lt;br /&gt;
            [relname] =&amp;gt; g:/joomla_1012/administrator&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
    [1] =&amp;gt; Array&lt;br /&gt;
        (&lt;br /&gt;
            [id] =&amp;gt; 2&lt;br /&gt;
            [parent] =&amp;gt; 1&lt;br /&gt;
            [name] =&amp;gt; backups&lt;br /&gt;
            [fullname] =&amp;gt; g:/joomla_1012/administrator/backups&lt;br /&gt;
            [relname] =&amp;gt; g:/joomla_1012/administrator/backups&lt;br /&gt;
        )&lt;br /&gt;
&lt;br /&gt;
    [2] =&amp;gt; Array&lt;br /&gt;
        (&lt;br /&gt;
            [id] =&amp;gt; 3&lt;br /&gt;
            [parent] =&amp;gt; 1&lt;br /&gt;
            [name] =&amp;gt; components&lt;br /&gt;
            [fullname] =&amp;gt; g:/joomla_1012/administrator/components&lt;br /&gt;
            [relname] =&amp;gt; g:/joomla_1012/administrator/components&lt;br /&gt;
        )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Clean a path string==&lt;br /&gt;
Syntax:&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
JFolder::makeSafe($path);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Identically to the JFile::makeSafe() function. It cleans all odd characters out of the string and returns a clean path.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
Ok, and how does this look in actual code. We are going to read the contents of a folder called images. In it, al large number of files are placed. We want to create a subfolder, called jpg and filter all jpg files out and move them to the jpg subfolder. After that, we will move the complete subfolder to another place on the server.&lt;br /&gt;
&amp;lt;source lang=php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// First we set up parameters&lt;br /&gt;
$searchpath = JPATH_COMPONENT . &#039;/images&#039;;&lt;br /&gt;
&lt;br /&gt;
// Import the folder system library&lt;br /&gt;
jimport(&#039;joomla.filesystem.folder&#039;);&lt;br /&gt;
&lt;br /&gt;
// Then we create the subfolder called jpg&lt;br /&gt;
if (!JFolder::create($searchpath . &amp;quot;/jpg&amp;quot;))&lt;br /&gt;
{&lt;br /&gt;
   // Throw error message and stop script&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Now we read all jpg files and put them in an array.&lt;br /&gt;
$jpgFiles = JFolder::files($searchpath, &#039;.jpg&#039;);&lt;br /&gt;
&lt;br /&gt;
// Now we need some stuff from the JFile:: class to move all files into the new folder&lt;br /&gt;
foreach ($jpgFiles as $file)&lt;br /&gt;
{&lt;br /&gt;
   JFile::move($searchpath . &#039;/&#039; . $file, $searchpath . &#039;/&#039; . &#039;jpg&#039; . $file);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Lastly, we are moving the complete subdir to the root of the component.&lt;br /&gt;
if (JFolder::move($searchpath . &#039;/&#039;. &#039;jpg&#039;, JPATH_COMPONENT))&lt;br /&gt;
{&lt;br /&gt;
   // Redirect with perhaps a happy message&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
   // Throw an error&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example script only, but gives a general idea of the possibilities.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Development]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tonypartridge</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Sending_email_from_extensions&amp;diff=357540</id>
		<title>Sending email from extensions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Sending_email_from_extensions&amp;diff=357540"/>
		<updated>2017-01-23T09:25:50Z</updated>

		<summary type="html">&lt;p&gt;Tonypartridge: . $send-&amp;gt;__toString() doesn&amp;#039;t exist and causes fatal error in J3.6.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Joomla version|version=2.5|time=and after}}&lt;br /&gt;
This is an example of how to send an email from a Joomla component. You would typically put this into your component&#039;s controller.&lt;br /&gt;
=== Fetch the Mail Object ===&lt;br /&gt;
A reference to the global mail object (JMail) is fetched through the JFactory object. This is the object creating our mail.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$mailer = JFactory::getMailer();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Set a Sender ===&lt;br /&gt;
The sender of an email is set with [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#setSender setSender]. The function takes an array with an email address and a name as an argument. We fetch the site&#039;s email address and name from the global configuration. These are set in the administration back-end (Global Configuration -&amp;gt; Server -&amp;gt; Mail Settings).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$config = JFactory::getConfig();&lt;br /&gt;
$sender = array( &lt;br /&gt;
    $config-&amp;gt;get( &#039;mailfrom&#039; ),&lt;br /&gt;
    $config-&amp;gt;get( &#039;fromname&#039; ) &lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
$mailer-&amp;gt;setSender($sender);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 3.1, $config-&amp;gt;getValue() should be changed to $config-&amp;gt;get()&lt;br /&gt;
&lt;br /&gt;
=== Recipient ===&lt;br /&gt;
You set the recipient of an email with the function [http://api.joomla.org/1.5/Joomla-Framework/Mail/JMail.html# addRecipient].&lt;br /&gt;
To set the email address to the currently logged in user, we fetch it from the user object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user = JFactory::getUser();&lt;br /&gt;
$recipient = $user-&amp;gt;email;&lt;br /&gt;
&lt;br /&gt;
$mailer-&amp;gt;addRecipient($recipient);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If we had multiple recipients, we would put each recipient&#039;s email address in an array.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$recipient = array( &#039;person1@domain.com&#039;, &#039;person2@domain.com&#039;, &#039;person3@domain.com&#039; );&lt;br /&gt;
&lt;br /&gt;
$mailer-&amp;gt;addRecipient($recipient);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create the Mail ===&lt;br /&gt;
We need to set a subject line and create the text body. The subject is set with [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#setSubject setSubject]. &lt;br /&gt;
&lt;br /&gt;
The easy way to create an email body is as a string with plain text. Use the function [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#setBody setBody] to add a message to the mail body. You can also attach a file with [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#addAttachment addAttachment]. It takes a single file name or an array of file names as the argument.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$body   = &amp;quot;Your body string\nin double quotes if you want to parse the \nnewlines etc&amp;quot;;&lt;br /&gt;
$mailer-&amp;gt;setSubject(&#039;Your subject string&#039;);&lt;br /&gt;
$mailer-&amp;gt;setBody($body);&lt;br /&gt;
// Optional file attached&lt;br /&gt;
$mailer-&amp;gt;addAttachment(JPATH_COMPONENT.&#039;/assets/document.pdf&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you prefer to format your email in HTML, you need to tell the mailer it is HTML. This is done with [http://api.joomla.org/Unknown/PHPMailer.html#methodIsHTML IsHTML]. When sending HTML emails you should normally set the [http://api.joomla.org/Unknown/PHPMailer.html#$Encoding Encoding] to base64 in order to avoid unwanted characters in the output. The subject line and any attachments are handled as above, with the exception of images embedded in the HTML. These are taken care of with the function [http://api.joomla.org/Unknown/PHPMailer.html#AddEmbeddedImage AddEmbeddedImage].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$body   = &#039;&amp;lt;h2&amp;gt;Our mail&amp;lt;/h2&amp;gt;&#039;&lt;br /&gt;
    . &#039;&amp;lt;div&amp;gt;A message to our dear readers&#039;&lt;br /&gt;
    . &#039;&amp;lt;img src=&amp;quot;cid:logo_id&amp;quot; alt=&amp;quot;logo&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&#039;;&lt;br /&gt;
$mailer-&amp;gt;isHtml(true);&lt;br /&gt;
$mailer-&amp;gt;Encoding = &#039;base64&#039;;&lt;br /&gt;
$mailer-&amp;gt;setBody($body);&lt;br /&gt;
// Optionally add embedded image&lt;br /&gt;
$mailer-&amp;gt;AddEmbeddedImage( JPATH_COMPONENT.&#039;/assets/logo128.jpg&#039;, &#039;logo_id&#039;, &#039;logo.jpg&#039;, &#039;base64&#039;, &#039;image/jpeg&#039; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Normally you would leave any images on your server and refer to them with an ordinary HTML image tag, to reduce size of the mail and the time sending it.&lt;br /&gt;
&lt;br /&gt;
=== Sending the Mail ===&lt;br /&gt;
The mail is sent with the function [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#Send Send]. It returns &#039;&#039;&#039;true&#039;&#039;&#039; on success or a JError object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$send = $mailer-&amp;gt;Send();&lt;br /&gt;
if ( $send !== true ) {&lt;br /&gt;
    echo &#039;Error sending email: &#039;;&lt;br /&gt;
} else {&lt;br /&gt;
    echo &#039;Mail sent&#039;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You would probably want to write your own error handler, if there is an error sending the mail.&lt;br /&gt;
&lt;br /&gt;
The JMail object is used for sending mail in Joomla&#039;s contact manager. See the file joomla/components/com_contact/controller.php&lt;br /&gt;
&lt;br /&gt;
===See also===&lt;br /&gt;
* [http://api.joomla.org/Joomla-Platform/JFactory.html#getMailer JFactory-&amp;gt;getMailer on api.joomla.org]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Tonypartridge</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Sending_email_from_extensions&amp;diff=357472</id>
		<title>Sending email from extensions</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Sending_email_from_extensions&amp;diff=357472"/>
		<updated>2017-01-20T15:26:16Z</updated>

		<summary type="html">&lt;p&gt;Tonypartridge: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Joomla version|version=2.5|time=and after}}&lt;br /&gt;
This is an example of how to send an email from a Joomla component. You would typically put this into your component&#039;s controller.&lt;br /&gt;
=== Fetch the Mail Object ===&lt;br /&gt;
A reference to the global mail object (JMail) is fetched through the JFactory object. This is the object creating our mail.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$mailer = JFactory::getMailer();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Set a Sender ===&lt;br /&gt;
The sender of an email is set with [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#setSender setSender]. The function takes an array with an email address and a name as an argument. We fetch the site&#039;s email address and name from the global configuration. These are set in the administration back-end (Global Configuration -&amp;gt; Server -&amp;gt; Mail Settings).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$config = JFactory::getConfig();&lt;br /&gt;
$sender = array( &lt;br /&gt;
    $config-&amp;gt;get( &#039;mailfrom&#039; ),&lt;br /&gt;
    $config-&amp;gt;get( &#039;fromname&#039; ) &lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
$mailer-&amp;gt;setSender($sender);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In 3.1, $config-&amp;gt;getValue() should be changed to $config-&amp;gt;get()&lt;br /&gt;
&lt;br /&gt;
=== Recipient ===&lt;br /&gt;
You set the recipient of an email with the function [http://api.joomla.org/1.5/Joomla-Framework/Mail/JMail.html# addRecipient].&lt;br /&gt;
To set the email address to the currently logged in user, we fetch it from the user object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user = JFactory::getUser();&lt;br /&gt;
$recipient = $user-&amp;gt;email;&lt;br /&gt;
&lt;br /&gt;
$mailer-&amp;gt;addRecipient($recipient);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If we had multiple recipients, we would put each recipient&#039;s email address in an array.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$recipient = array( &#039;person1@domain.com&#039;, &#039;person2@domain.com&#039;, &#039;person3@domain.com&#039; );&lt;br /&gt;
&lt;br /&gt;
$mailer-&amp;gt;addRecipient($recipient);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create the Mail ===&lt;br /&gt;
We need to set a subject line and create the text body. The subject is set with [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#setSubject setSubject]. &lt;br /&gt;
&lt;br /&gt;
The easy way to create an email body is as a string with plain text. Use the function [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#setBody setBody] to add a message to the mail body. You can also attach a file with [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#addAttachment addAttachment]. It takes a single file name or an array of file names as the argument.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$body   = &amp;quot;Your body string\nin double quotes if you want to parse the \nnewlines etc&amp;quot;;&lt;br /&gt;
$mailer-&amp;gt;setSubject(&#039;Your subject string&#039;);&lt;br /&gt;
$mailer-&amp;gt;setBody($body);&lt;br /&gt;
// Optional file attached&lt;br /&gt;
$mailer-&amp;gt;addAttachment(JPATH_COMPONENT.&#039;/assets/document.pdf&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you prefer to format your email in HTML, you need to tell the mailer it is HTML. This is done with [http://api.joomla.org/Unknown/PHPMailer.html#methodIsHTML IsHTML]. When sending HTML emails you should normally set the [http://api.joomla.org/Unknown/PHPMailer.html#$Encoding Encoding] to base64 in order to avoid unwanted characters in the output. The subject line and any attachments are handled as above, with the exception of images embedded in the HTML. These are taken care of with the function [http://api.joomla.org/Unknown/PHPMailer.html#AddEmbeddedImage AddEmbeddedImage].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$body   = &#039;&amp;lt;h2&amp;gt;Our mail&amp;lt;/h2&amp;gt;&#039;&lt;br /&gt;
    . &#039;&amp;lt;div&amp;gt;A message to our dear readers&#039;&lt;br /&gt;
    . &#039;&amp;lt;img src=&amp;quot;cid:logo_id&amp;quot; alt=&amp;quot;logo&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&#039;;&lt;br /&gt;
$mailer-&amp;gt;isHtml(true);&lt;br /&gt;
$mailer-&amp;gt;Encoding = &#039;base64&#039;;&lt;br /&gt;
$mailer-&amp;gt;setBody($body);&lt;br /&gt;
// Optionally add embedded image&lt;br /&gt;
$mailer-&amp;gt;AddEmbeddedImage( JPATH_COMPONENT.&#039;/assets/logo128.jpg&#039;, &#039;logo_id&#039;, &#039;logo.jpg&#039;, &#039;base64&#039;, &#039;image/jpeg&#039; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Normally you would leave any images on your server and refer to them with an ordinary HTML image tag, to reduce size of the mail and the time sending it.&lt;br /&gt;
&lt;br /&gt;
=== Sending the Mail ===&lt;br /&gt;
The mail is sent with the function [http://api.joomla.org/Joomla-Framework/Mail/JMail.html#Send Send]. It returns &#039;&#039;&#039;true&#039;&#039;&#039; on success or a JError object.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$send = $mailer-&amp;gt;Send();&lt;br /&gt;
if ( $send !== true ) {&lt;br /&gt;
    echo &#039;Error sending email: &#039; . $send-&amp;gt;__toString();&lt;br /&gt;
} else {&lt;br /&gt;
    echo &#039;Mail sent&#039;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You would probably want to write your own error handler, if there is an error sending the mail.&lt;br /&gt;
&lt;br /&gt;
The JMail object is used for sending mail in Joomla&#039;s contact manager. See the file joomla/components/com_contact/controller.php&lt;br /&gt;
&lt;br /&gt;
===See also===&lt;br /&gt;
* [http://api.joomla.org/Joomla-Platform/JFactory.html#getMailer JFactory-&amp;gt;getMailer on api.joomla.org]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Component Development]]&lt;/div&gt;</summary>
		<author><name>Tonypartridge</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=Client-side_form_validation&amp;diff=352759</id>
		<title>Client-side form validation</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=Client-side_form_validation&amp;diff=352759"/>
		<updated>2017-01-03T06:05:43Z</updated>

		<summary type="html">&lt;p&gt;Tonypartridge: Added information about lists&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{JSplit}}&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Joomla 1.5 and later versions contain a behavior, which allows your form and its elements to be validated at client side, i.e., before it is submitted to the server. The behavior enables the script &#039;&#039;&#039;validate.js&#039;&#039;&#039; and used [http://mootools.net MooTools] up to version 3.2 and jQuery from version 3.3.&lt;br /&gt;
&lt;br /&gt;
Note: Validate.js is a validation system different from the one provided by [http://mootools.net/docs/more/Forms/Form.Validator MooTools].&lt;br /&gt;
&lt;br /&gt;
==Enable the Validation==&lt;br /&gt;
&lt;br /&gt;
Add a behavior to your form view template. For Joomla versions before 1.5.2:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtmlBehavior::formvalidation();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
For versions from 1.5.2 to 3.3.6:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtml::_(&#039;behavior.formvalidation&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
For versions from 3.4:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHtml::_(&#039;behavior.formvalidator&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the form-validate class to your form&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;form class=&amp;quot;form-validate&amp;quot;&amp;gt; ... &amp;lt;/form&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add a validation class to your form field declarations. Joomla adds a &#039;&#039;blur&#039;&#039; handler to validate the form field when the user moves away from the field.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;field name=&amp;quot;email&amp;quot; type=&amp;quot;text&amp;quot; class=&amp;quot;required validate-email&amp;quot; size=&amp;quot;30&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//For radios make sure the class is applied to the options: &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;field name=&amp;quot;ThisorThat&amp;quot; type=&amp;quot;radio&amp;quot; label=&amp;quot;Please say if it was full-time or the part-time equivalent?&amp;quot; &amp;gt;&lt;br /&gt;
 &amp;lt;option value=&amp;quot;This&amp;quot; class=&amp;quot;required&amp;quot;&amp;gt;This&amp;lt;/option&amp;gt;&lt;br /&gt;
 &amp;lt;option value=&amp;quot;That&amp;quot; class=&amp;quot;required&amp;quot;&amp;gt;That&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;
For lists which are required the first option should have a value of &amp;quot;&amp;quot; as per:&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;selectme&amp;quot; type=&amp;quot;list&amp;quot; required=&amp;quot;true&amp;quot; label=&amp;quot;Please say if it was full-time or the part-time equivalent?&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;This&amp;quot;&amp;gt;This&amp;lt;/option&amp;gt;&lt;br /&gt;
 &amp;lt;option value=&amp;quot;That&amp;quot;&amp;gt;That&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;
The following classes are available:&lt;br /&gt;
* required&lt;br /&gt;
* validate-username&lt;br /&gt;
* validate-password&lt;br /&gt;
* validate-numeric&lt;br /&gt;
* validate-email&lt;br /&gt;
* validate-[custom] -&amp;gt; custom defined - see below&lt;br /&gt;
&lt;br /&gt;
Note: Joomla 2.5 translates the &#039;&#039;required&#039;&#039; field attribute into a &#039;&#039;required&#039;&#039; class value.&lt;br /&gt;
&lt;br /&gt;
Finally, add the &#039;&#039;validate&#039;&#039; class to your submit button. This will cause an &#039;&#039;onclick&#039;&#039; handler to be added that validates the whole form. The form will only be submitted if it is valid.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;button type=&amp;quot;submit&amp;quot; class=&amp;quot;validate&amp;quot;&amp;gt;Submit form&amp;lt;/button&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Custom Handlers==&lt;br /&gt;
&lt;br /&gt;
If you want a custom handler, you can add one to the class, as in the following example (to be defined AFTER loading validate.js):&lt;br /&gt;
&lt;br /&gt;
MooTools&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
window.addEvent(&#039;domready&#039;, function(){&lt;br /&gt;
   document.formvalidator.setHandler(&#039;birth&#039;, function(value) {&lt;br /&gt;
      regex=/^\d{4}-\d{2}-\d{2}$/;&lt;br /&gt;
      return regex.test(value);&lt;br /&gt;
   });&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
jQuery&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
jQuery(document).ready(function(){&lt;br /&gt;
   document.formvalidator.setHandler(&#039;birth&#039;, function(value) {&lt;br /&gt;
      regex=/^\d{4}-\d{2}-\d{2}$/;&lt;br /&gt;
      return regex.test(value);&lt;br /&gt;
   });&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
You can then assign validate-birth to any field to make it validate as yyyy-mm-dd.  (Valid date is not checked!)&lt;br /&gt;
&lt;br /&gt;
If you want a custom handler to check both the passwords (Password and Confirm Password) are same, please add the following script after the validate.js:&lt;br /&gt;
&lt;br /&gt;
MooTools&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
window.addEvent(&#039;domready&#039;, function(){&lt;br /&gt;
    document.formvalidator.setHandler(&#039;passverify&#039;, function (value) {&lt;br /&gt;
        return ($(&#039;password&#039;).value == value); &lt;br /&gt;
    });&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jQuery&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
jQuery(document).ready(function(){&lt;br /&gt;
    document.formvalidator.setHandler(&#039;passverify&#039;, function (value) {&lt;br /&gt;
        return (jQuery(&#039;input[type=password]&#039;).value == value); &lt;br /&gt;
    });&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Add the class &amp;quot;validate-passverify&amp;quot; to the input field as below:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&amp;lt;input class=&amp;quot;inputbox required validate-passverify&amp;quot; type=&amp;quot;password&amp;quot; id=&amp;quot;password2&amp;quot; name=&amp;quot;password2&amp;quot; size=&amp;quot;40&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Styling/Templating Invalid Elements==&lt;br /&gt;
&lt;br /&gt;
Joomla assigns the &#039;&#039;invalid&#039;&#039; class to form fields that do not pass the validation test. &#039;&#039;invalid&#039;&#039; is also added to the field labels.&lt;br /&gt;
If you style the class in the cascading style sheet, your users will be able to see which fields are wrong. For instance:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
.invalid {&lt;br /&gt;
    border-color: red !important;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Some site templates may already contain such definition. (This one is taken from &#039;&#039;beez_20&#039;&#039;.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Only Accept the Form After Validation==&lt;br /&gt;
     This section is not necessary, if it works at all. See validate class on submit buttons.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem &amp;amp; workaround with JToolBar==&lt;br /&gt;
If you are using JHTML::_(&#039;behavior.formvalidation&#039;) with JToolBar, for example use in backend, the above method will not work. This is because it depends on onSubmit event which did not fire when we call form.submit via JavaScript. To work around this, we have to move the code in onSubmit to be in submitbutton function override. This will look like this:-&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
/* Override joomla.javascript, as form-validation not work with ToolBar */&lt;br /&gt;
function submitbutton(pressbutton) {&lt;br /&gt;
    if (pressbutton == &#039;cancel&#039;) {&lt;br /&gt;
        submitform(pressbutton);&lt;br /&gt;
    }else{&lt;br /&gt;
        var f = document.adminForm;&lt;br /&gt;
        if (document.formvalidator.isValid(f)) {&lt;br /&gt;
            f.check.value=&#039;&amp;lt;?php echo JUtility::getToken(); ?&amp;gt;&#039;; //send token&lt;br /&gt;
            submitform(pressbutton);    &lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
            var msg = new Array();&lt;br /&gt;
            msg.push(&#039;Invalid input, please verify again!&#039;);&lt;br /&gt;
            if ($(&#039;title&#039;).hasClass(&#039;invalid&#039;)) {&lt;br /&gt;
                msg.push(&#039;&amp;lt;?php echo JText::_(&#039;COM_JONGMAN_ERROR_SCHEDULE_TITLE_IS_REQUIRED&#039;)?&amp;gt;&#039;);    &lt;br /&gt;
            }&lt;br /&gt;
            if($(&#039;admin_email&#039;).hasClass(&#039;invalid&#039;)){&lt;br /&gt;
                msg.push(&#039;&amp;lt;?php echo JText::_(&#039;COM_JONGMAN_ERROR_INVALID_EMAIL&#039;)?&amp;gt;&#039;);&lt;br /&gt;
            }&lt;br /&gt;
            alert (msg.join(&#039;\n&#039;));&lt;br /&gt;
        }&lt;br /&gt;
    }    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==More on mootools validation==&lt;br /&gt;
More available classes on the mootools site here: [http://mootools.net/docs/more/Forms/Form.Validator#Validators http://mootools.net/docs/more/Forms/Form.Validator#Validators]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Server- or Client-side validation?==&lt;br /&gt;
[[Form validation]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;[[Category:Tutorials]][[Category:Development]][[Category:Component Development]]&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tonypartridge</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=List_form_field_type&amp;diff=352758</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=352758"/>
		<updated>2017-01-03T06:00:38Z</updated>

		<summary type="html">&lt;p&gt;Tonypartridge: &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;
&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;
&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;
&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;&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;=== See also === &amp;lt;!--T:13--&amp;gt;&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;
* [[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;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:15--&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>Tonypartridge</name></author>
	</entry>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=List_form_field_type&amp;diff=352757</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=352757"/>
		<updated>2017-01-03T05:57:40Z</updated>

		<summary type="html">&lt;p&gt;Tonypartridge: Shows JForm XML which is required.&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;
&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;
&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;
&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;&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;=== See also === &amp;lt;!--T:13--&amp;gt;&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;
* [[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;
&amp;lt;translate&amp;gt;&lt;br /&gt;
&amp;lt;!--T:15--&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>Tonypartridge</name></author>
	</entry>
</feed>