diff --git a/src/form.lisp b/src/form.lisp index 2eac3e2..3494fe4 100644 --- a/src/form.lisp +++ b/src/form.lisp @@ -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