clog/clog-form.lisp
2021-01-11 01:26:55 -05:00

53 lines
2.2 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-obj)()
(: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 ;;
;;;;;;;;;;;;;;;;;;;;;;;;
(defgeneric create-form-element (clog-form)
(: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 (clog-form)
(create-child obj "<input />" :clog-type 'clog-form-element :auto-place auto-place))