Appsilon / shiny.semantic

Shiny support for powerful Fomantic UI library.
http://appsilon.github.io/shiny.semantic
Other
499 stars 97 forks source link

Form Validation #386

Open ashbaldry opened 3 years ago

ashbaldry commented 3 years ago

The {shinyvalidate} package doesn't seem to work with {shiny.semantic}. However Fomantic UI has out of the box form validation. It would be good to include this in the package.

I've been working on a POC of this, by being able to add the validation at the end of a form. It also includes a submission button, that will only trigger reactive events if the form passes validation.

Example:

  library(shiny)
  library(shiny.semantic)

  ui <- semanticPage(
    form(
      id = "form",
      field(
        tags$label("Name"),
        text_input("name")
      ),
      field(
        tags$label("E-Mail"),
        text_input("email")
      ),
      form_validation(
        id = "form",
        field_valitaion("name", field_rule("empty"))
        field_valitaion("email", field_rule("empty"), field_rule("email"))
      )
    )
  )

  server <- function(input, output) {
  }

  shinyApp(ui, server)

https://user-images.githubusercontent.com/8420419/137782312-d2011813-faf1-4fec-b582-bd8657b700dd.mp4