[Import patches to library from Golgonooza's simple-form clinton@unknownlamer.org**20090130084149 A few important notes: * The tiny bit that is not formulaic copying from ucw_ajax I relicense under the same BSD license as the rest of ucw-forms * The `validp' and `form-fields-of' methods for `date-field' should be replaced with a pair specialized on a `compound-field'. * `default-validp' is of suspect quality (i.e. I wrote it this way and I don't like it, but it works so I'll look at it in a bit). ] hunk ./src/form.lisp 80 -(defmethod validp ((component standard-component)) - "Loops over COMPONENT's slots, checks whethere all slots which - contain form-field objects are valid. +(defgeneric form-fields-of (component)) hunk ./src/form.lisp 82 -As second value returns list of conses (invalid-field . failed-validator)." - ;;summary are we valid? +(defmethod form-fields-of ((component standard-component)) + "Return slot values of COMPONENT which are FORM-FIELDs" + (remove-if-not #'ucw-forms::form-field-p + (mapcar (arnesi:curry #'slot-value component) + (remove-if-not #'(lambda (name) (slot-boundp component name)) + (mapcar #'c2mop:slot-definition-name + (c2mop:class-slots (class-of component))))))) + +(defmethod form-fields-of ((field form-field)) + (list field)) + +(defun default-validp (form) + ;; Mostly yanked from ucw update (C) notices hunk ./src/form.lisp 100 - failed))) - - (form-fields-of (component) - "Return slot values of COMPONENT which are FORM-FIELDs" - (remove-if-not #'form-field-p - (mapcar (curry #'slot-value component) - (remove-if-not #'(lambda (name) (slot-boundp component name)) - (mapcar #'c2mop:slot-definition-name - (c2mop:class-slots (class-of component)))))))) + failed)))) hunk ./src/form.lisp 103 - (form-fields-of component))))) + (form-fields-of form))))) hunk ./src/form.lisp 106 +(defmethod validp ((form standard-component)) + (default-validp form)) + hunk ./src/form.lisp 430 +(defmethod validp ((form-field date-field)) + (default-validp form-field)) + +(defmethod form-fields-of ((field date-field)) + (list (year field) (month field) (day field))) + hunk ./src/package.lisp 55 - #:phone-number-validator)) + #:phone-number-validator + + #:form-fields-of + #:default-validp ; not sure if this should be exported + ))