consentUI | R Documentation |
Shiny UI function for displaying a participant consent form
consentUI(id = "consent", title = "Consent Form", filename = NULL)
id |
The input ID associated with the consent module. Must match the ID of |
title |
The title of the consent form. Defaults to "Consent Form." |
filename |
The name of the file containing the consent form text. This must be an HTML file stored in the app's |
A user interface that displays a custom consent form from a separate file, buttons for the participant to consent or decline, and (optionally) an opportunity for the participant to explicitly agree to audio recording.
Events can be added to the "agree" button by accessing it among the app's inputs with the following (replace id
with the id
you supplied for the module): input[["id-agree"]]
.
Must be used with consentServer
. If cons2rec = TRUE
, consider using recordUI
and recordServer
.
Other Consent form module:
consentServer()
if (interactive()) {
ui <- shiny::fluidPage(
shiny::actionButton("ok", "OK"),
consentUI(id = "cons"),
textOutput("result")
)
server <- function(input, output, session) {
consent <- consentServer(id = "cons",
trigger = shiny::reactive(input$ok),
delayResponse = 3000,
agreeId = "agree",
disagreeLab = "Decline",
disagreeId = "disagree",
cons2rec = TRUE)
shiny::observeEvent(input$ok, {
shinyjs::hide("ok")
})
# Show the output value when the participant agrees.
shiny::observeEvent(input$agree, {
output$result <- shiny::renderText({consent$agree})
})
}
shiny::shinyApp(ui = ui, server = server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.