Browse Source

add condition check to checkbox-to-bool and remove bool-to-checkbox.

stable
Craig Oates 2 years ago
parent
commit
eb62ade5be
  1. 14
      src/utils.lisp

14
src/utils.lisp

@ -13,7 +13,6 @@
#:set-alert
#:get-alert
#:get-and-reset-alert
#:bool-to-checkbox
#:checkbox-to-bool
#:asciify
#:slugify)
@ -72,21 +71,12 @@ POST request."
(set-alert nil)
message))
(defun bool-to-checkbox (value)
"Converts `VALUE' so it can populate an HTML checkbox.
It is assumed you are converting a SQLite version of a Boolean so
either 1 (true) or 0 (false). If you need a traditional Boolean value,
DO NOT USE THIS FUNCTION."
(cond ((= value 0) "off")
((null value) "off")
(t "on")))
(defun checkbox-to-bool (value)
"Converts a HTML Checkbox `VALUE' to a Boolean.
The `VALUE' will either be 'on' or 'off'. 'Boolean' in this instance
is assuming you are using SQLite and need to convert `VALUE' to an
integer/number. If you are needing a traditional Boolean value, DO NOT USE
THIS FUNCTION."
(cond ((string= "checked" value) +true+)
((string= "off" value) +false+)
(cond ((or (string= "checked" value) (string= "on" value)) +true+)
((or (string= "off" value) (null value)) +false+)
((null value) +false+)))

Loading…
Cancel
Save