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.

Details

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.

Public fields

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.

Methods

Public methods


Method new()

Initialises a ShinyForm.

Usage

ShinyForm$new(id, submit, onSuccess, onError, ...)

Arguments

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.


Method ui()

Returns the form's UI. To be used inside your App's UI.

Usage

ShinyForm$ui()


Method 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.

Usage

ShinyForm$server(input, output)

Arguments

input

Shiny input.

output

Shiny output.


Method getValue()

Returns value of the input element with a given ID.

Usage

ShinyForm$getValue(input, inputId)

Arguments

input

Shiny input.

inputId

ID of the input whose value is to be returned.


Method clone()

The objects of this class are cloneable with this method.

Usage

ShinyForm$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.