mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 10:40:45 -08:00
66 lines
2.6 KiB
Common Lisp
66 lines
2.6 KiB
Common Lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;;; CLOG - The Common Lisp Omnificent GUI ;;;;
|
|
;;;; (c) 2020-2021 David Botton ;;;;
|
|
;;;; License BSD 3 Clause ;;;;
|
|
;;;; ;;;;
|
|
;;;; clog-form.lisp ;;;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(cl:in-package :clog)
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Implementation - clog-form
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defclass clog-form (clog-element)()
|
|
(:documentation "CLOG Form Objecs is the base class for all html forms."))
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;
|
|
;; create-form ;;
|
|
;;;;;;;;;;;;;;;;;
|
|
|
|
(defgeneric create-form (clog-obj &key auto-place)
|
|
(:documentation "Create a new CLOG-Form as child of CLOG-OBJ that organizes
|
|
a collection of form elements in to a singnle form if :AUTO-PLACE (default t)
|
|
place-inside-bottom-of CLOG-OBJ. In CLOG a form's on-submit handler should be
|
|
set and the form elelement values handled in that handler as opposed to the
|
|
HTML model of submitting to a new \"page\"."))
|
|
|
|
(defmethod create-form ((obj clog-obj) &key (auto-place t))
|
|
(create-child obj "<form />" :clog-type 'clog-form :auto-place auto-place))
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Implementation - clog-form-clement
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defclass clog-form-element (clog-element)()
|
|
(:documentation "CLOG Form Element Object is the base class for all form
|
|
elements."))
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; create-form-elemnt ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(deftype form-element-type ()
|
|
'(member :button :checkbox :color :date :datetime :datetime-local :email
|
|
:file :hidden :image :month :number :password :radio :range
|
|
:reset :search :submit :tel :text :time :url :week))
|
|
|
|
(defgeneric create-form-element (clog-form element-type &key name value)
|
|
(:documentation "Create a new clog-form-element as child of CLOG-FORM.
|
|
clog-form-elements are always placed with in the CLOG-FORM in the DOM"))
|
|
|
|
(defmethod create-form-element ((obj clog-form) element-type
|
|
&key (name nil) (value ""))
|
|
(create-child obj (format nil "<input type='~A' form='~A' value='~A' ~A/>"
|
|
(escape-string element-type)
|
|
(html-id obj)
|
|
value
|
|
(if name
|
|
(format nil "name='~A'" name)
|
|
""))
|
|
:clog-type 'clog-form-element :auto-place t))
|
|
|