I've had the same problem. I've seen two choices :
- Make the select choice a step in the workflow (you chose, you click next and the form appears)
- You do it in javascript (what I have done). You put a callback on your select, and use jQuery
show()
and hide()
functions. If you have mandatory fields, you nedd to handle that too.
This is what I've done and it worked, but I would be glad if anyone have a more elegant solution.
Edit : in my case, I was making a custom component, and then had a template (ftl) and a script file (js).
In this js, once the page is initialized, I added a section of code to handle what I need. The code I'm putting is just for the example :
$('#select_id').change(function(){
showHideMyComponent($(this).val());
});
function showHideCible(value){
boolean hide = checkIfIhaveToHide(value);
if(hide){
$("#divToHandle").hide();
}else{
$("#divToHandle").show();
}
}