| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/input-submit.R |
| 3 |
\name{submitButton} |
| 4 |
\alias{submitButton} |
| 5 |
\title{Create a submit button} |
| 6 |
\usage{ |
| 7 |
submitButton(text = "Apply Changes", icon = NULL, width = NULL) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{text}{Button caption} |
| 11 |
|
| 12 |
\item{icon}{Optional \code{\link[=icon]{icon()}} to appear on the button} |
| 13 |
|
| 14 |
\item{width}{The width of the button, e.g. \code{'400px'}, or \code{'100\%'}; |
| 15 |
see \code{\link[=validateCssUnit]{validateCssUnit()}}.} |
| 16 |
} |
| 17 |
\value{ |
| 18 |
A submit button that can be added to a UI definition. |
| 19 |
} |
| 20 |
\description{ |
| 21 |
Create a submit button for an app. Apps that include a submit |
| 22 |
button do not automatically update their outputs when inputs change, |
| 23 |
rather they wait until the user explicitly clicks the submit button. |
| 24 |
The use of \code{submitButton} is generally discouraged in favor of |
| 25 |
the more versatile \code{\link[=actionButton]{actionButton()}} (see details below). |
| 26 |
} |
| 27 |
\details{ |
| 28 |
Submit buttons are unusual Shiny inputs, and we recommend using |
| 29 |
\code{\link[=actionButton]{actionButton()}} instead of \code{submitButton} when you |
| 30 |
want to delay a reaction. |
| 31 |
See \href{https://shiny.rstudio.com/articles/action-buttons.html}{this article} for more information (including a demo of how to "translate" |
| 32 |
code using a \code{submitButton} to code using an \code{actionButton}). |
| 33 |
|
| 34 |
In essence, the presence of a submit button stops all inputs from |
| 35 |
sending their values automatically to the server. This means, for |
| 36 |
instance, that if there are \emph{two} submit buttons in the same app, |
| 37 |
clicking either one will cause all inputs in the app to send their |
| 38 |
values to the server. This is probably not what you'd want, which is |
| 39 |
why submit button are unwieldy for all but the simplest apps. There |
| 40 |
are other problems with submit buttons: for example, dynamically |
| 41 |
created submit buttons (for example, with \code{\link[=renderUI]{renderUI()}} |
| 42 |
or \code{\link[=insertUI]{insertUI()}}) will not work. |
| 43 |
} |
| 44 |
\examples{ |
| 45 |
if (interactive()) { |
| 46 |
|
| 47 |
shinyApp( |
| 48 |
ui = basicPage( |
| 49 |
numericInput("num", label = "Make changes", value = 1), |
| 50 |
submitButton("Update View", icon("refresh")), |
| 51 |
helpText("When you click the button above, you should see", |
| 52 |
"the output below update to reflect the value you", |
| 53 |
"entered at the top:"), |
| 54 |
verbatimTextOutput("value") |
| 55 |
), |
| 56 |
server = function(input, output) { |
| 57 |
|
| 58 |
# submit buttons do not have a value of their own, |
| 59 |
# they control when the app accesses values of other widgets. |
| 60 |
# input$num is the value of the number widget. |
| 61 |
output$value <- renderPrint({ input$num }) |
| 62 |
} |
| 63 |
) |
| 64 |
} |
| 65 |
} |
| 66 |
\seealso{ |
| 67 |
Other input elements: |
| 68 |
\code{\link{actionButton}()}, |
| 69 |
\code{\link{checkboxGroupInput}()}, |
| 70 |
\code{\link{checkboxInput}()}, |
| 71 |
\code{\link{dateInput}()}, |
| 72 |
\code{\link{dateRangeInput}()}, |
| 73 |
\code{\link{fileInput}()}, |
| 74 |
\code{\link{numericInput}()}, |
| 75 |
\code{\link{passwordInput}()}, |
| 76 |
\code{\link{radioButtons}()}, |
| 77 |
\code{\link{selectInput}()}, |
| 78 |
\code{\link{sliderInput}()}, |
| 79 |
\code{\link{textAreaInput}()}, |
| 80 |
\code{\link{textInput}()}, |
| 81 |
\code{\link{varSelectInput}()} |
| 82 |
} |
| 83 |
\concept{input elements} |