-
-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
Problem
Cask has no form handling utilities. Users must manually:
- Render forms with scalatags
- Parse form data
- Validate input (manual if-else chains)
- Display errors (manual)
// Current - everything manual
@cask.get("/users/new")
def newUser() = {
import scalatags.Text.all._
html(
body(
form(action := "/users", method := "post")(
input(name := "name", `type` := "text"),
input(name := "email", `type` := "email"),
button("Create User")
)
)
).render
}
@cask.post("/users")
def create(name: String, email: String) = {
// Manual validation
if (name.isEmpty) cask.Abort(400, "Name required")
if (!email.contains("@")) cask.Abort(400, "Invalid email")
User.create(name, email)
cask.Redirect("/users")
}- Repetitive validation code
- No validation, form handling, error display
Solution
binding, simple validation, rendering with scalatags.
- form data binding to scalatags
- simple validations - throw Throwables
- Scalatags from functions
Questions -
- What form helpers are essential (text, email, password, select, etc.)?
- repopulation after errors?
- Multi-step forms
- No field-level error tracking
References
- scalatags for rendering
- uPickle for data binding
Metadata
Metadata
Assignees
Labels
No labels