In my reprex below, Number duplicates the inputs. I am stuck on how to achieve two things.
If the Contractor radio button option is selected, show a text input with label "Name of Contractor".
How can I have the radio button input set as empty? I know
selected = character(0)
achieves this, but it causes another challenge: if an option is selected, and then Number is changed, the radio button selection will disappear. In my reprex, the radio button selection will not be affected after Number is changed, but the default selection is the first choice, whereas I would like the default to be empty.
library(shiny)
ui <- fluidPage(
numericInput("n", "Number", value = 1),
uiOutput("col")
)
server <- function(input, output, session) {
# Dynamic UI: Multiple Controls -------------------------------------------
col_names <- reactive(paste0("staff_attended_", seq_len(input$n)))
output$col <- renderUI({
map(
col_names(),
~ tagList(
selectInput(
.x,
label = "Staff Attended",
choices = letters,
selected = isolate(input[[.x]]),
multiple = TRUE
),
radioButtons(
paste0(.x, "_type"),
"Staff Attended: Shift/Call-In/Contractor?",
choices = c("Shift", "Call-In", "Contractor"),
selected = isolate(input[[paste0(.x, "_type")]])
)
)
)
})
}
shinyApp(ui, server)