> examples that don't feel like working for me. So, how are per-view > validator functions meant to be used? Ie. I have the following code > (in weblocks-demo): > > (defun validate-age (&rest args &key age age-field &allow-other-keys)
Ah, the standard weblocks validation system does not support this, this is a hackish addition I made to views. It is enabled by overriding validate-object-form-view. Here is the original code, my changes, and at the bottom, an example of use. http://paste.lisp.org/display/83293 So far, the most complex validation I have is a hefty 130 lines, and one really useful thing is the ability to modify the dataform's :data object in the validation function. So for example, if a date-field is set a certain way, you can react to it programmatically by setting appropriate values for other slots. > (defview employee-form-view (:type form :inherit-from 'person-form- > (inspired by the comments in contrib/nunb/templates-crufty/template- > form-view.lisp). But each time I get: You need to either: 1. take the entire code from there and include it in your project (see paste above). [note that then you'll need to use (defview :type templform ... ) in place of (defview :type form ..) ] 2. or, if you don't need arbitrary error-message generation, use normal weblocks views instead. It is expected that the view-validators will be a list of functions, and they get run only if all the fields have individually passed their satisfies functions. From validate- object-form-view: (if (form-view-satisfies view) (run-view-validators (form-view-satisfies view) fields-values) t) > I understand that I'm supposed to return a VIEW-FIELD object, but what > I don't understand is where I'm supposed to get it. The validation > function isn't given one. This is because you have defview :type form which only expects the view-satisfies to take a list of fields-values. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "weblocks" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/weblocks?hl=en -~----------~----~----~----~------~----~------~--~---
