How do you hide or show form controls dynamically ? For example, I would like to show a textarea only when an option is selected in a select.
Is there any show() or hide() method?
I tried myForm.hideItem(“item_id”) but it’s not working for v.6.
It seems to have disappeared from the documentation, so this might be in the process of changing, but what has been working in DHX6 for me so far (and still works on 6.4.2) is to use setConfig on the item:
myForm.getItem("item_id").setConfig({...hidden:true});
The “…” is there because you have to duplicate the original config of the item and add the “hidden” member. The id, name, and type of the form item cannot be changed, so you can leave those out of the new configuration object.
Repaint is the trick:
dhxForm.getItem("myfield").config.hidden = true;
dhxForm.getItem("myfield").paint();
Thanks, that’s fine for controls that have “hidden” in their properties but not for the others unfortunatly…
UNfortunaetly currently it is not available to hide any dhtmlxForm control.
But we’re planning to extensd that feature in the future.
In the dhtmlxSuite 7.0 we’ve added the possibility to hide the needed dhtmlxForm control using the hide() method or withe hidden:true property in the config.
https://docs.dhtmlx.com/suite/form__api__form_hidden_property.html
https://docs.dhtmlx.com/suite/form__api__form_hide_method.html