ShinyForm can be used to include forms in your website. Create
a ShinyForm
object anywhere in your application by
defining all the inputs (possibly adding validators) and by
specifying callback onSuccess
and onError
functions.
Parameters onSuccess
and onError
passed to the constructor
should be functions with signatures function(self, input, output)
,
where `self` will refer to the form itself, while input
and
output
will be the usual Shiny objects.
id
Unique form id which can be used with Shiny input.
elements
A list of ShinyForm input elements.
onSuccess
A function with to be run on valid submission, see details.
onError
A function with to be run on invalid submission, see details.
submit
A submit Action button/link.
new()
Initialises a ShinyForm.
ShinyForm$new(id, submit, onSuccess, onError, ...)
id
Unique form identifier.
submit
Submit button label.
onSuccess
Function to be ran on successful validation.
onError
Function to be ran on unsuccesful validation.
...
A list of validated Shiny inputs.
ui()
Returns the form's UI. To be used inside your App's UI.
ShinyForm$ui()
server()
Form logic. To be inserted into your App's server function.
Will validate form upon hitting the "Submit" button and run the `onSuccess` or `onError` function depending on whether the form is valid.
ShinyForm$server(input, output)
input
Shiny input.
output
Shiny output.
getValue()
Returns value of the input element with a given ID.
ShinyForm$getValue(input, inputId)
input
Shiny input.
inputId
ID of the input whose value is to be returned.
clone()
The objects of this class are cloneable with this method.
ShinyForm$clone(deep = FALSE)
deep
Whether to make a deep clone.