| controlInput | R Documentation |
Wrap Shiny input controller to: - detect whether its value was changed by the user or programmatically (with 'update*' functions), - block sending the value to the server depending on the change source, - attach custom attributes to the input value.
The original input handler (e.g. converting 'shiny::dateInput' value to 'Date') is applied before attributes are attached.
controlInput(controller, block = NULL, trigger = TRUE, attributes = list())
controller |
Shiny input controller e.g. 'shiny::selectInput' or 'shinyWidgets::pickerInput'. |
block |
Sources of value change that should not be sent to the server. Any of '"user"' (change made directly in the browser) and '"program"' (change made with 'update*' function). The initial value is always sent. |
trigger |
When 'TRUE', the value has '"trigger"' attribute attached that stores source of the change: '"init"' (initial value or the controller was rendered), '"user"' or '"program"'. |
attributes |
Named list of extra (static) attributes attached to the input value. |
The attributes can't be attached to 'NULL' values, so in this case the input value is passed as is.
Nested list of 'shiny.tag' objects - the 'controller' with extra attributes and dependency attached.
if (interactive()) {
library(shiny)
ui <- fluidPage(
controlInput(selectInput("letter", "Letter", letters), attributes = list(group = "form")),
controlInput(numericInput("number", "Number", value = 1), block = "program"),
actionButton("update", "Update programmatically"),
verbatimTextOutput("out")
)
server <- function(input, output, session) {
output$out <- renderPrint({
str(list(letter = input$letter, number = input$number))
})
observeEvent(input$update, {
updateSelectInput(session, "letter", selected = sample(letters, 1))
# value updated in browser but not sent to the server
updateNumericInput(session, "number", value = sample(1:10, 1))
})
}
shinyApp(ui, server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.