form_validation {fomantic.plus} | R Documentation |
Form Validation for Fomantic UI
Description
A form validation behaviour checks data against a set of criteria before passing it along to the server.
Usage
form_validation(
id,
...,
submit_label = "Submit",
submit_class = "",
include_button = TRUE,
inline = FALSE
)
Arguments
id |
ID of the parent form |
... |
A series of |
submit_label |
Label to give the submission button at the end of the form (included in returned UI with input
value |
submit_class |
Additional classes to give the submission button |
include_button |
Logical, should the submit button be included? Defaults to |
inline |
Logical, do you want the field validation errors as in-line labels ( |
Details
In order for the validation to work, the form_validation
must be a direct child of the form
.
The "Submit" button has an input value of {id}_submit
and will only trigger
server-side events if all the fields pass validation.
NB If you do not include either form validation input as part of the server-side code then the inputs will pass through to the server as if there were no validation.
Value
A shiny.tag.list
containing the inline JS to perform the form validation in the shiny UI.
If include_button = TRUE
then a button will also be included to appear in the UI.
References
https://fomantic-ui.com/behaviors/form.html
See Also
Examples
if (interactive()) {
library(shiny)
library(shiny.semantic)
library(fomantic.plus)
ui <- semanticPage(
tags$head(
extendShinySemantic()
),
form(
id = "form",
field(
tags$label("Name"),
text_input("name")
),
field(
tags$label("E-Mail"),
text_input("email")
),
form_validation(
id = "form",
field_validation("name", field_rule("empty")),
field_validation("email", field_rule("empty"), field_rule("email"))
)
)
)
server <- function(input, output) {
}
shinyApp(ui, server)
}