Add linked parent-child inputs (cascading dropdowns)
add_linked_inputs.RdCreates two linked select inputs where the child's available options depend on
the parent's current selection. Use inside a sidebar (after add_sidebar()).
Arguments
- x
A sidebar_container (from
add_sidebar()).- parent
List with:
id,label,options; optionallydefault_selected,filter_var.- child
List with:
id,label,options_by_parent(named list mapping each parent value to a character vector of child options); optionallyfilter_var.- type
Input type for parent:
"select"(default) or"radio".
Examples
if (FALSE) { # \dontrun{
add_sidebar() %>%
add_linked_inputs(
parent = list(id = "dimension", label = "Dimension",
options = c("AI", "Safety", "Digital Health")),
child = list(id = "question", label = "Question",
options_by_parent = list(
"AI" = c("Overall", "Using AI Tools"),
"Safety" = c("Overall", "Passwords", "Phishing"),
"Digital Health" = c("Overall", "Screen Time")
))
) %>%
end_sidebar()
} # }