Это связано с неправильной ссылкой на идентификатор. Ваш inputiD
равен "type"
, а в вашем conditionalPanel()
вы ссылаетесь на "source
". Поэтому измените все input.source
на input.type
, и это будет работать.
Итак, ваш код выглядит следующим образом:
ui <- fluidPage(
h1("Reminder to do X"),
sidebarLayout(
sidebarPanel(
radioButtons(
inputId = "type",
label = "Reminder Type",
choices = c("Single Date Reminder" = "single",
"Multi Date Reminder" = "multi",
"From-To Reminder" = "from_to"),
selected = "single", width = '100%'
)
),
mainPanel(
conditionalPanel(
condition = "input.type == 'single'",
dateInput("single_date", "Enter the date for your reminder", value = Sys.Date())
),
conditionalPanel(
condition = "input.type == 'multi'",
dateRangeInput("multi_date_1",
label = "Enter from to dates",
start = Sys.Date(),
end = Sys.Date() + 7,
autoclose = TRUE)
),
conditionalPanel(
condition = "input.type == 'from_to'",
dateRangeInput("multi_date_2",
label = "Enter from to dates",
start = Sys.Date(),
end = Sys.Date() + 7,
autoclose = TRUE)
)
)
)
)
shinyApp(ui, server = function(input, output) { })
И вывод:
ОБНОВЛЕНИЕ
Я немного изменил ваш код и включил один пример airDatepickerInput()
. Поэтому я изменил эту часть вашего кода
conditionalPanel(
condition = "input.type == 'multi'",
dateRangeInput("multi_date_1",
label = "Enter from to dates",
start = Sys.Date(),
end = Sys.Date() + 7,
autoclose = TRUE)
)
На эту
conditionalPanel(
condition = "input.type == 'multi'",
airDatepickerInput(
inputId = "multiple",
label = "Select multiple dates:",
placeholder = "You can pick 3 dates",
multiple = 3, clearButton = TRUE
)
)
И это вывод:
Обратите внимание, что если вы также хотите выбрать время, вставьте timepicker = TRUE
внутри airDatepickerInput()