2

I have a form field which needs to be shown depending on value selected for another field. For example

<field name="field1" type="list" label="LABEL1" description="DESC1" filter="intval" size="1" default="0" class="form-control">
  <option value="0">Option 0</option>
  <option value="1">Option 1</option>
</field>
<field name="field2" showon="field1:1" type="list" label="LABEL2" description="DESC2" filter="intval" size="1" default="0" class="form-control">
  <option value="3">Option 3</option>
  <option value="4">Option 4</option>
</field>

In my above code, field2 will be shown only when field1 value is 1. This works fine from the front-end form. However the same form does not work in my admin component. Is there any special JavaScript file needs to be loaded for this to work?

0

1 Answer 1

8

Found what the issue is. I was using getInput function to show the field.

$this->form->getInput('field2'); 

but showon attribute working only if I render the field using renderField function

$this->form->renderField('field2'); 

Hope this helps someone facing the same issue

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.