Set specific condition for hidden form ctrl and align naming

This commit is contained in:
Marcus Kammer 2024-08-04 16:29:21 +02:00
parent 91b11dd920
commit c932c338fa
Signed by: marcuskammer
GPG key ID: C374817BE285268F

View file

@ -173,36 +173,39 @@ LABEL: The label to display next to the control."
(id-str (build-str-id name label)))
(spinneret:with-html
(:comment (format nil "FORM/CTRL ~A ~A" type name))
(:div :class (spacing :property "m" :side "b" :size 3)
(:label :class class-str
:for id-str
label)
(:input :class "form-control"
:id id-str
:type type
:name name-str)))))
(if (string= type "hidden")
(:input :class "form-control"
:id id-str
:type type
:name name-str
:value label)
(:div :class (spacing :property "m" :side "b" :size 3)
(:label :class class-str
:for id-str
label)
(:input :class "form-control"
:id id-str
:type type
:name name-str))))))
(defmacro define-ctrl (type)
"Generates a checkable function based on the provided type.
TYPE: A string representing checkable-element."
(let ((func-name (intern (string-upcase (concatenate 'string "ctrl-" type)))))
`(defun ,func-name (name value)
(ctrl ,type name value))))
`(defun ,func-name (name label)
(ctrl ,type name label))))
(defmacro define-ctrls ()
(defmacro define-ctrls (&rest types)
"Generates multiple checkable functions based on the provided list of types.
TYPES: A list of strings that specifies the types for which to generate
checkable macros."
`(progn
,@(loop for type in '("button" "checkbox" "color" "date" "datetime-local"
"email" "file" "hidden" "image" "month" "number"
"password" "radio" "range" "reset" "search" "submit"
"tel" "text" "time" "url" "week")
,@(loop for type in types
collect `(define-ctrl ,type))))
(define-ctrls)
(define-ctrls "button" "checkbox" "color" "date" "datetime-local" "email" "file" "hidden" "image" "month" "number" "password" "radio" "range" "reset" "search" "submit" "tel" "text" "time" "url" "week")
;;; combo