0

I would like to extend the functionality of my form I'm using in my admin-backend.

To to that I would like to use the showon-attribute, which should only show a field, if the value of this field is -1:

<field  name="itemid" 
        type="sql"  
        label="COM_BESTIA_FIELD_ITEMS" 
        query="SELECT id, title FROM #__bestia_items WHERE state = 1" 
        key_field="id" 
        value_field="title" 
        required="true">
            <option value="-1">Other</option>
</field>

How can I do this: showon itemid:-1 does not work.

2

You can show/hide your field with showon when the value of related field matches your defined values for showon. So there should be two fields minimum:

  1. Field with values to match.
  2. Field to show/hide.

For example:

<field  name="itemid" 
        type="sql"  
        label="COM_BESTIA_FIELD_ITEMS" 
        query="SELECT id, title FROM #__bestia_items WHERE state = 1" 
        key_field="id" 
        value_field="title" 
        required="true">
            <option value="-1">Other</option>
</field>

<field  name="custom" 
        type="sql"  
        label="COM_BESTIA_FIELD_ITEMS" 
        query="SELECT id, title FROM #__bestia_items WHERE state = 1" 
        key_field="id" 
        value_field="title" 
        required="true"
        showon="itemid:-1">
            <option value="-1">Other</option>
</field>

So here your custom field will be displayed when value of itemid field is -1.

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.