Let's say I have the following shiny app:
library(shiny)
shinyApp(
ui=fluidPage(
selectizeInput(
inputId = "foo",
label = NULL,
choices = c("a", "b"),
options = list(
create = TRUE
)
)
),
server=function(input, output, session){
}
)
It is a pretty simple app in which I have a dropdown list generated with selectize.js
. The create
option will allow the user to input a custom selection as input (something different than a or b).
If the user type something, it will display the following:
I would like that, when the user clicks on "Add c...", the app would save a file in the app repertory named c.txt
containing the string "hello". The documentation of selectize.js
suggests the create
option can take either a boolean or a function as its argument so, I was guessing intuitively that writing something like
create = function(input){write("hello", paste0(input, ".txt"))}
instead of create = TRUE
would work, but it is not.
Anyone could help me with this?