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