XML
Joomla! 6
Joomla! 5
Joomla! 4
Component
Intermediate
Define a Repeatable Subform and Conditional showon Fields in XML
Combines a switcher toggle, zero-JS showon conditional visibility and a draggable multiple subform in Joomla XML forms.
administrator/components/com_example/forms/item.xml
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="options" label="COM_EXAMPLE_OPTIONS">
<field name="enable_blocks" type="radio"
layout="joomla.form.field.radio.switcher"
label="COM_EXAMPLE_ENABLE_BLOCKS" default="0">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="blocks" type="subform"
label="COM_EXAMPLE_BLOCKS"
multiple="true" buttons="add,remove,move"
showon="enable_blocks:1">
<form>
<field name="title" type="text" label="JGLOBAL_TITLE" required="true" />
<field name="url" type="url" label="COM_EXAMPLE_URL" scheme="http,https" />
</form>
</field>
</fieldset>
</form>
Supports [AND] and [OR] operators inside showon expressions.
Technical explanation and best practices
Joomla native showon="field:value" lets you hide advanced controls until enabled without writing any custom admin JavaScript.