我正在开发一个闪亮的仪表板,用户可以在点击send email
按钮时发送电子邮件。当用户点击发送电子邮件时,需要在各种输入字段上执行验证。这是我的ui.R
文件看起来像
tabItem("email",
fluidRow(
box(
width = 5, status = "info",solidHeader = TRUE,
title = "Send Emails",
helpText(tags$b("If no selection is made, emails will be sent to all the registrants with today's date")),
dateRangeInput('dateRange',
label = 'Date Range Input',
start = c("",Sys.Date() - 2), end = c("",Sys.Date() + 2)
),
selectizeInput("email_select",
"Select Email Content",
choices = c("Price" = "price",
"Services" = "service"
),
options = list(
placeholder = 'Please select',
onInitialize = I('function() { this.setValue(""); }')
)
),
uiOutput("city_dropdown")
)
)
uiOutput
是一个下拉框,一旦上传数据就会填充。这是我的server.R
文件,看起来像
shinyServer(function(input, output, session) {
output$city_dropdown <- renderUI({
city <- reg_city(final_data)
city <- city$registrant_city
city <- as.list(city)
selectizeInput("city_select",
"Select City",
choices = city,
options = list(
placeholder = 'Please select',
onInitialize = I('function() { this.setValue("");}')
)
)
})
observeEvent(input$send_email, {
city <- input$city_select
if(city == ""){
validate(
need(input$city_select != '', 'Please choose a city')
)}
但是当我点击操作按钮时没有任何反应,如果没有从下拉框中选择城市,则不会显示错误消息。 请帮忙。