I created a simple module to enter values in textfields which I show in module positions on the frontend (banner images...).

Now I need a solution like if dropdown value in fieldname "xy" is "xyz" then show me another xml field.

Is this possible?


You can use Joomla's showon attribute in your field.

Here's an exmaple:

<field name="first" type="list" label="Select Something">
    <option value="1">Option 1</option>
    <option value="2">Option 2</option>
    <option value="3">Option 3</option>

<field name="second" type="list" label="Select Something Else" showon="first:3">
    <option value="1">Other Option 1</option>
    <option value="2">Other Option 2</option>
    <option value="3">Other Option 3</option>

The above example will only show the second field if option 3 is selected from the first field, using showon="first:3".

In the showon attribute, you need to define the name of the field and the value

Hope this helps

| improve this answer | |
  • If I want to show/hide fields based module selected language it doesn't seem to work showon="language:en-CA" . Any solution? – Ejaz Feb 22 '18 at 20:10
  • @Ejaz - You're going to have to create a custom form field for that – Lodder Feb 22 '18 at 20:11
  • is it compulsory to have value in numeric? as i am trying showon="fieldname:fieldvalue" and it is not working where fieldvalue is not numeric – Rahul Kaushik Mar 7 '18 at 5:49
  • @Rahul Kaushik I dont believe it needs to be numeric – Lodder Mar 7 '18 at 8:46
  • @RahulKaushik for the purposes of translation it is sometimes preferable to use values instead of words. For example your fieldvalue maybe in a language I do not understand but if you keep values as 0, 1, 2 that becomes less relevant, the only thing that needs to change is the label and description which can be language strings. Alternately, if you wish to use values, you should use language strings as the values so they can be translated. If you can imagine I am doing an output of if ($params['field'] == "unblikenstageden" {do something} that's a long word that I am not familiar spelling – Eoin Jun 9 '18 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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