1

I have various such pairs in a form:

<field
        name="hasEndDate"
        type="list"
        label="Hat Enddatum?"
        default="1"
>
    <option value="0">Nein</option>
    <option value="1">Ja</option>
</field>

<field
        name="endDate"
        type="calendar"
        translateformat="true"
        singleheader="false"
        showtime="true"
        timeformat="24"
        todaybutton="true"
        label="Ende: Datum und Zeit"
        weeknumbers="true"
        size="20"
        filter="server_utc"
        showon="hasEndDate:1"
/>

While the first showon in the first tab of the edit form makes the field appear / disappear, all other suchlike marked fields, never disappear.

I tried different types of the source field - no change at all.

  • Any ideas why?
  • Is the showon operation only guaranteed on the first tab?

1 Answer 1

2

The showon feature of XML fields's settings in Joomla works well in Joomla 4 according to my tests. The issue that 'showon' works or not does not have too much to do with HTML Tabs basically, but it has a lot to do with XML Fields and Field. You create HTML Tabs and display different Fieldsets/Fields/Field within the different Tabs and the fields within the tabs are usually within different Fields nodes in the XML.

For example you have X number of Tabs and you set a showon condition for a field in your 5th Fieldsets/Fields (in 5th Tab of your Form) dependent on a Field value in 4th Fieldsets' Fields' (in 4th Tab), then you should target the <Field> of the targeted particular <Fields> node when you are setting a showon condition, like "fieldsname.fieldname:1", so you not only set fieldname:1.

That way in your 5th Tab the field with a showon condition - targeting the 4th Tab's field value - will respond according to the 4th Tabs field value setting.

In my test XML you can see this setting in the different <Fieldsets> and <Fields>. For you the last <Field> is interesting to check in this example.

<fieldset name = "showg">
    <fields name="showfieldsg">
       <field
                name="hasEndDate"
                type="list"
                label="Hat Enddatum?"
                default="1"
        >
            <option value="0">Nein</option>
            <option value="1">Ja</option>
        </field>

        <field
                name="endDate"
                type="calendar"
                translateformat="true"
                singleheader="false"
                showtime="true"
                timeformat="24"
                todaybutton="true"
                label="Ende: Datum und Zeit"
                weeknumbers="true"
                size="20"
                filter="server_utc"
                showon="hasEndDate:1"
        />
        <field
                name="nextTabValue"
                type="list"
                label="Next Tab Field show?"
                default="1"
        >
            <option value="0">No</option>
            <option value="1">Yes</option>
        </field>
    </fields>
</fieldset>
<fieldset name = "showi">
    <fields name="showfieldsi">
        <field
                name="TestPrevTab"
                type="list"
                label="Test Previous Tab Setting"
                default="1"
                showon="showfieldsg.nextTabValue:1"
        >
            <option value="0">No</option>
            <option value="1">Yes</option>
        </field>
    </fields>
</fieldset>

So shortly, within the same Fieldsets' Fields the showon condition works as usual but if one of your fields depends on another Fieldset's Fields value then you should target the Fieldsname.Fieldname in the showon condition and it will work.

And the visual working result of these tabs and field's showon test in Tabs is here:

https://imagizer.imageshack.com/img923/1135/Himm8V.gif

2
  • 1
    Sounds good, Zollie! I'd check that. I think, that I referenced fields within the same tab/fieldset. But let's see. Will come back.
    – SteAp
    Commented Apr 24, 2023 at 21:40
  • 1
    Quite likely, I assigned two tabs identical names. Therefore, things didn't work as expected. Thanks again for your assistance!
    – SteAp
    Commented Apr 24, 2023 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.