You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given that you can pass value = "" to timeInput() and start with an empty form, i expected that i could pass the same argument to updateTimeInput, but that throws an error. Also passing value = NULL doesn't work and just keeps the existing values. Is there any way to clear the fields?
Curiously, what does work is to instead use updateTextInput(), and passing an empty string as value, but that seems rather kludgy..
library(shiny)
library(shinyTime)
ui <- fluidPage(
titlePanel("shinyTime Example App"),
sidebarLayout(
sidebarPanel(
timeInput("time_input1", "Enter time", value = ""),
timeInput("time_input2", "Enter time (5 minute steps)", value = "", minute.steps = 5),
actionButton("to_current_time", "Current time"),
actionButton("clear_time", "Clear")
),
mainPanel(
textOutput("time_output1"),
textOutput("time_output2")
)
)
)
server <- function(input, output, session) {
output$time_output1 <- renderText(strftime(input$time_input1, "%T"))
output$time_output2 <- renderText(strftime(input$time_input2, "%R"))
observeEvent(input$to_current_time, {
updateTimeInput(session, "time_input1", value = Sys.time())
updateTimeInput(session, "time_input2", value = Sys.time())
})
observeEvent(input$clear_time, {
updateTextInput(session, "time_input1", value = "")
updateTextInput(session, "time_input2", value = "")
})
}
shinyApp(ui, server)
The text was updated successfully, but these errors were encountered:
Given that you can pass
value = ""
totimeInput()
and start with an empty form, i expected that i could pass the same argument toupdateTimeInput
, but that throws an error. Also passingvalue = NULL
doesn't work and just keeps the existing values. Is there any way to clear the fields?Curiously, what does work is to instead use
updateTextInput()
, and passing an empty string asvalue
, but that seems rather kludgy..The text was updated successfully, but these errors were encountered: