Joomla XML Form

The Joomla! XML forms are used to define form fields, field sets and field groups.

All the forms start with the XML definition and the form tag. You define the fields, field sets and field groups in between the form.

<?xml version="1.0" encoding="utf-8"?>
<form>

</form>

1. Field Sets

You can put multiple fields in the field set. This is useful to display each field set under different tab. For example, 

<fieldset name="details" label="JDETAILS">

</fieldset>

2. Field Groups

You can group multiple fields with the fields tag. All the fields in one group will be returns in array. This is useful when you want to store multiple fields in one column as json. For example,

<fields name="params">

</fields>

You can add field sets inside field groups or vice-versa.

3. Field

Some common fields used by multiple extensions are given below:

1. Title

<field
    name="title"
    type="text"
    label="JGLOBAL_TITLE"
    required="true" />

2. Alias

<field
    name="alias"
    type="text"
    label="JFIELD_ALIAS_LABEL"
    description="JFIELD_ALIAS_DESC"
    hint="JFIELD_ALIAS_PLACEHOLDER" />

3. Id

<field
    name="id"
    type="text"
    label="JGLOBAL_FIELD_ID_LABEL"
    class="readonly"
    default="0"
    readonly="true" />

4. State or Published

<field
    name="state"
    type="list"
    label="JSTATUS"
    class="form-select-color-state"
    default="1"
    validate="options">
        <option value="1">JPUBLISHED</option>
        <option value="0">JUNPUBLISHED</option>
        <option value="2">JARCHIVED</option>
        <option value="-2">JTRASHED</option>
</field>

5. Modified Date

<field
    name="modified"
    type="calendar"
    label="JGLOBAL_FIELD_MODIFIED_LABEL"
    class="form-control"
    translateformat="true"
    showtime="true"
    readonly="true"
    filter="user_utc" />

6. Ordering

<field
    name="ordering"
    type="text"
    label="JFIELD_ORDERING_LABEL"
    default="0" />

7. Access

<field
    name="access"
    type="accesslevel"
    label="JFIELD_ACCESS_LABEL"
    filter="UINT"
    validate="options" />

8. Hits

<field
    name="hits"
    type="text"
    label="JGLOBAL_HITS"
    readonly="true"
    filter="unset"
    default="0" />

9. Language

<field
    name="language"
    type="contentlanguage"
    label="JFIELD_LANGUAGE_LABEL">
        <option value="*">JALL</option>
</field>

10. Author

<field
    name="author"
    type="text"
    label="JAUTHOR" />

Here is the list of all the form field types available in Joomla.

4. Inline Help

To display inline help button on the toolbar, add the following code just below opening form tag.

<config>
    <inlinehelp button="show"/>
</config>

This button will toggle (show or hide) description of the fields.