Hide field based on value of checkbox

Hello everyone,

I wanted to add the functionality to a checkbox such that if the checkbox is ticked(“checked”) the options below it should should be shown else they should remain hidden.

By javascript I am able to achive the above but there are 2 problems:

  1. I want the fields to be hidden by default(ie. when the editview is opened they should not show, as the checkbox is not ticked by default).
  2. When I tick the checkbox the fields do get hidden but they overoccupy the space available and the layout becomes clumsy and bad. I understand there needs to be some changes that need to be done to the template files, but I am unable to move forward. I am also reading about the smarty template and its documentation.

Any help or maybe some clues would be very helpful.

Thanks

you can workaround this by assigning one row in studio to that field, did you try that?

best regards

Hello there.

You need to use javascript listeners (using jquery or yui) to make it less hardcoded, e.g. jQuery.click(checkbox-element) and jQuery.load(document) (check documentation).
You need to group dynamic fields (which has to be hidden depending on checkbox state) inside one “div” to separate them from others visually and for easier manipulation.

Hence using custom view class to possibly avoid touching core files.