Well i trying to open a window by pressing a button to write some text inputs and submit to MySql table, like this example below, but i dont know how i centralize the texts inputs.
library(shinyWidgets)
library(shiny)
library(shinyjs)
library(RMariaDB)
shinyApp(
ui = fluidPage(
useShinyjs(), # Set up shinyjs
actionButton("btn", "Customer Registration"),
),
server = function(input, output,session) {
#connect to MySQL
#localuserpassword= "PASSW"
#myconnect <- dbConnect(RMariaDB::MariaDB(), user='user', password=localuserpassword, dbname='name', host='localhost')
observeEvent(input$btn, { # open a window by pressing the "btn" button
confirmSweetAlert(
btn_labels = c("Cancel","Submit"),
session = session,
inputId = "SubmitCustomertoSQL",
type = "info",
title = paste0("Customer Registration"),
danger_mode = F,
closeOnClickOutside = T,
showCloseButton =T,
text = tags$div(
renderUI(textInput("name", "Name")),
renderUI(textInput("NRLE", "National Registry of Legal Entities")),
renderUI(textInput("address", "Address")),
)
)
} )
observeEvent(input$SubmitCustomertoSQL, {
#Send to MySQL
#querycustomer= paste("insert into TABLENAME(Name,NRLE,Addres)
# values('",input$name,"','",
# input$NRLE,"','",
# input$address,
# "')" ,sep = '')
#dbSendQuery(myconnect, querycustomer)
})
}
)
How to centralize the text input and save then into a object?
Include align = 'center'
in your div, e.g. text = tags$div(align = 'center',
textInput
can also include placeholder text if you want to match the example more closely.
Minimal working example
library(shinyWidgets)
library(shiny)
library(shinyjs)
shinyApp(
ui = fluidPage(
useShinyjs(),
actionButton("btn", "Customer Registration"),
),
server = function(input, output,session) {
observeEvent(input$btn, {
confirmSweetAlert(
btn_labels = c("Cancel","Submit"),
session = session,
inputId = "SubmitCustomertoSQL",
type = "info",
title = paste0("Customer Registration"),
danger_mode = F,
closeOnClickOutside = T,
showCloseButton =T,
text = tags$div(align = 'center',
renderUI(textInput("name", "Name")),
renderUI(textInput("NRLE", "National Registry of Legal Entities")),
renderUI(textInput("address", "Address")),
)
)
})
})