我修改了 dspace 代码的反馈表以添加一个类别,该类别将询问用户他们的“用户类型”。
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",""));
}
我的目标是仅当用户选择 Other 时才显示文本区域。此外,如果用户选择其他,则文本区域应该是必填字段。我怎样才能做到这一点?我也想尝试使用单选按钮而不是选择。
[编辑] 对于那些不熟悉 DSpace 的人,这是我从 DSpace github 修改的原始代码:反馈表