From b69746436fe2b417d16aa0b4ef5ceab8ee9f3c71 Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Sun, 23 Jun 2024 09:11:47 +0200 Subject: [PATCH] Add with-form macro --- src/form.lisp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/form.lisp b/src/form.lisp index 40aaeed..9a3291d 100644 --- a/src/form.lisp +++ b/src/form.lisp @@ -61,7 +61,8 @@ :ctrl-url :ctrl-week :ctrl-element - :search-form)) + :search-form + :with-form)) (in-package :dev.metalisp.sbt/form) @@ -486,3 +487,22 @@ Example 1: collect `(:option ,value)))) `(progn ,@(loop for value in values collect `(:li (apply-input-form ,type ,group ,value)))))))))))) + +(defmacro with-form (&body body) + "Create a standardized HTML form wrapped in a
tag with a pre-defined +class and structure, using the Spinneret library. The form is designed to be +used within a web application served by Hunchentoot, utilizing common layout +and localization practices. The macro automatically sets the form’s action to +the current request URI and expects certain functions and variables to be +available in its environment for full functionality." + `(spinneret:with-html + (:main :id "main-content" + :class "container my-5" + (:p "Please fill out the following forms and press the submit button.") + ;; action is defined as hunchentoot:request-uri* function + (:form :action (request-uri*) + :method "post" + :class (spacing :property "m" :side "y" :size 5) + ,@body + (btn-primary (:type "submit") + (find-l10n "submit" ml-survey:*html-lang* *l10n*))))))