For a component I have a field item_type
that needs to be saved in its own database column for ease of searching, filtering etc, and a set of configurations which have global option defaults so are stored as parameters in the database params column for the component eg item_colour
item_size
etc.
So the item_type field in the form xml appears in the main fieldset and the parameters fields appear in the params fieldset.
I want to use showon
field attributes in the form to determine which fields will show depending on the setting of item type. In the edit view I want to render the fields all on the same tab rather than use a separate tab for params.
My problem is that showon
only seems to work with fields in the same fieldset. Is there any syntax that will get showon to work with a field in a different fieldset.
So the form xml looks like this
<form>
<fieldset name="default">
<field name="item_type" type="list"
label="Select type" description=""
>
<option value="0">Basic</option>
<option value="1">Simple</option>
<option value="2">Complex</option>
</field>
</fieldset>
<fields name="params">
<fieldset name="params" label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS" >
<field name="item_colour" type="color"
label="Colour" description=""
default="#0000ff" format="hex"
showon="item_type:1"
/>
<field name="item_icon" type="text"
label="Icon" description=""
default=""
showon="item_type:2"
/>
</fieldset>
</fields>
</form>
and the edit.php includes this
<?php echo $this->form->renderField('item_type'); ?>
<?php echo $this->form->renderField('item_colour','params'); ?>
<?php echo $this->form->renderField('item_icon','params'); ?>
The problem is that the showon conditions do not work. If I move the item type field into the params fieldset and change it to <?php echo $this->form->renderField('item_type','params'); ?>
then it works, but of course the item_type gets saved as a parameter, not in its own column.