I modified the feedback form of dspace code to add a category that will ask the user for their 'user type'.
Select category = form.addItem().addSelect("category");
category.setLabel("Please select your category");
category.addOption("UG","Undergraduate/BS");
category.addOption("MS","MS Student");
category.addOption("PHD","PhD Student");
category.addOption("FAC","Faculty");
category.addOption("RES","Researcher");
category.addOption("TRA","Trainee");
category.addOption("BUS","Businessman/Private");
category.addOption("FF","Fish farmer");
category.addOption("OT","Other");
String itemSelected = parameters.getParameter("category","");
if (StringUtils.equals(itemSelected,"OT"))
{
TextArea other = form.addItem().addTextArea("other");
other.setHelp("Write here if you selected Other");
other.setValue(parameters.getParameter("other",""));
}
My goal here is to display a text area only if the user selected Other. Also, the text area should be a required field if the user choose other. How can I achieve this? I would also like to try using radio buttons instead of select.
[EDIT] For those who are not familiar with DSpace, here's the original code that I modified from DSpace github: feedback form