TextInput: TextInput

Description Usage Arguments Details Value See Also Examples

View source: R/TextInput.R

Description

This is a series of textInputs fields with a functionality for validating the provided text inputs.

Usage

1
TextInput(input, output, session, n, checkFun = NULL, addArgs = NULL)

Arguments

input

argument used by shiny session

output

argument used by shiny session

session

argument used by shiny session

n

int number of textInput fields. n must be length(labels) from FileUploadUI.

checkFun

chr or NULL (NULL) if not NULL name of a function which can be used as a quality check for textInputs

addArgs

list or NULL (NULL) if not NULL list of additional arguments which will be passed to checkFun

Details

With argument checkFun a function name can be defined which will be used as quality control for the text inputs. This function must take a chr arr as first argument. These are the user provided text inputs. The function must either return NULL or a chr value. NULL means the input is valid. Thereby the module returns this chr arr. If the user input should not be valid, the function must return a character value. This chr value will be rendered as a error message for the user, and the modul returns NULL.

Additional argumets can be handed over to checkFun via the list addArgs.

Value

chr arr of user provided text input fields or NULL

See Also

Other TextInput module functions: TextInputUI

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(shinyTools)

# some function as example
check <- function(text, add){ if(any(grepl(add$pat, text))) return(paste("Don't use letter", add$pat, "in any entry."))}

# little app with module
ui <- fluidPage(sidebarLayout(
  sidebarPanel(h2("TextInputUI"),
               TextInputUI("id1", c("positive Ctrls", "non-targeting Ctrls"), c("positive", "non-targeting"),
                           help = "use HGNC symbols", horiz = FALSE)
  ),
  mainPanel(h2("Output of TextInput"), verbatimTextOutput("display"))
))

server <-function(input, output, session) {
  display <- callModule(TextInput, "id1", n = 2, checkFun = "check", addArgs = list(pat = "X"))
  output$display <- renderPrint(display())
}

shinyApp(ui, server)

mRcSchwering/shinyTools documentation built on May 21, 2017, 4:43 p.m.