fix to legacy checkbox.
authorDrew Crampsie <drewc@tech.coop>
Thu, 2 Feb 2006 06:59:55 +0000 (22:59 -0800)
committerDrew Crampsie <drewc@tech.coop>
Thu, 2 Feb 2006 06:59:55 +0000 (22:59 -0800)
This is also good code to steal for a BOOLEAN attribute.

darcs-hash:20060202065955-5417e-796ac4caf58b5b7907fcf90cbafbb4d96e6b94f6.gz

src/static-presentations.lisp

index 5958f3b..68541d9 100644 (file)
@@ -422,7 +422,21 @@ This method is also used by relation-slot-presentations for the same reason."))
   (:type-name boolean))
 
 (defmethod present-slot ((slot boolean-slot-presentation) instance)
   (:type-name boolean))
 
 (defmethod present-slot ((slot boolean-slot-presentation) instance)
-  (<ucw:input :type "checkbox" :accessor (presentation-slot-value slot instance)))
+  (if (editablep slot)
+    (let ((callback (ucw::make-new-callback
+                  (lambda (val)
+                    
+                    (if (listp val)
+                        (setf (presentation-slot-value slot instance) t)
+                        (setf (presentation-slot-value slot instance) nil))))))
+    (<:input :type "hidden" :name callback :value "DEFAULT")
+    (<:input :type "checkbox"
+            :name callback
+            :checked  (slot-value instance (slot-name slot))))
+    (<:as-html
+     (if (presentation-slot-value slot instance)
+        "YES"
+        "NO"))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;; strings
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;; strings