The subform form field type provides a method for using XML forms inside one another or reuse forms inside an existing form. If attribute multiple is set to true then the included form will be repeatable.

The Field has two predefined layouts for displaying the subform as either a table or as a div container, as well as support for custom layouts.

The subform form field does not provide the Validation and Filters for child fields.

Example XML field definition:

<field name="field-name" 
type="subform"
formsource="path/to/exampleform.xml"
label="Subform Field"
description="Subform Field Description" />

Mandatory Parameters

  • type must be subform.

  • name is the unique name of the field.

  • label (translatable) is the descriptive title of the field.

  • formsource - 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 JForm::getInstance().

Optional Parameters

  • description (translatable) is text that will be shown as a tooltip when the user moves the mouse over the drop-down box.

  • required - The field must be filled before submitting the form.

  • message - The error message that will be displayed instead of the default message.

  • default is the default value, JSON string.

  • multiple - whether the subform fields are repeatable or not.

  • min - count of minimum repeating in multiple mode. Default: 0.

  • max - count of maximum repeating in multiple mode. Default: 1000.

  • groupByFieldset - whether to group the subform fields by its fieldset (true or false). Default: false.

  • buttons - which buttons to show in multiple mode. Default: add,remove,move.

  • layout - the name of the layout to use when displaying subform fields.

Layout

The layouts are saved in the folder: layouts/joomla/form/field/subform

For example, you can have: layout="joomla.form.field.subform.repeatable-table"