[Enhance simple-form error checking and display clinton@unknownlamer.org**20080209054051 * A list of error messages is now displayed after each erring element * Error checking is done in process-form and the form is flagged as invalid so that errors are only displayed after the form has been submitted ] { hunk ./src/packages.lisp 73 - :defgeneric/cc :defmethod/cc) + :defgeneric/cc :defmethod/cc + :compose) hunk ./src/web.lisp 32 - - hunk ./src/web.lisp 69 - ()) + ((%invalid :initform nil :accessor form-invalid-p))) hunk ./src/web.lisp 106 +(defmethod/cc process-form :around ((form simple-form)) + (multiple-value-bind (validp failed) (validp form) + (cond ((not validp) + (setf (form-invalid-p form) t) + (refresh-component form)) + (t (setf (form-invalid-p form) nil) + (call-next-method))))) + hunk ./src/web.lisp 123 - (mapc (lambda (c) - (<:div :class "field-box" ; composite field-box (car c)? - (<:div :class "label" - (<:as-html (symbol->string (car c))) - (multiple-value-bind (validp failed) (validp (cdr c)) - (if (not validp) - (<:div :class "error" - (<:as-html "Invalid"))))) - (<:div :class "widget" (render (cdr c))))) - (form-fields form)))) + (mapc + (lambda (c) + (<:div + :class "field-box" ; composite field-box (car c)? + (<:div :class "label" + (<:as-html (symbol->string (car c))) + (if (form-invalid-p form) + (multiple-value-bind (validp failed) (validp (cdr c)) + (if (not validp) + (<:div :class "error" + (<:format "Invalid ~@[(~{~A~^, ~})~]" + (mapcan (lambda (v) + (if-bind msg (ucw::message v) + (list msg) + msg)) + failed))))))) + (<:div :class "widget" (render (cdr c))))) + (form-fields form)))) + hunk ./src/web.lisp 168 + ;; Mostly yanked from ucw update (C) notices hunk ./src/web.lisp 181 - ;; Mostly yanked from ucw update (C) notices }