On Fri, Mar 5, 2010 at 12:58 AM, Mark <[email protected]> wrote: > Hi Mike, > > I have a form with some hidden fields that were dynamically added by > another operation going on in the same page. These hidden fields were > formed with values that were already validated. I do not wish to > validate this again. Can I use __unpackargs__ to specify the fields I > want to validate and just leave the ones that I don't want out of the > list? Is this what __unpackargs__ does?
__unpackargs__ is just a convenience for setting instance attributes. It doesn't do anything more than that. It's up to the rest of the class code to do something with the values. > So for example I have a form with first_name, last_name, course_name, > enrollment_limit,....and some hidden fields (these are also repeating > fields) like: sess-1.name, sess-1.start, sess-2.name, > sess-2.start....and so on. What do I have to do to prevent > sess-1.name, sess-1.start, sess-2.name, sess-2.start from validating, > but still I want them to be added to my object. > Seems like the only solution is to re-validate them and use > Formencode's solution of repeating fields to solve this.... Why not use the String validator? It always succeeds. Or you can define just the regular fields, and use ``allow_extra_fields=True; filter_extra_fields=False` to pass through the other fields (the 'sess' fields). But: * It's arguably bad form to use fields that don't have an explicit validator. It suggests you're not security-controlling those fields. * I'm not sure if NestedVariables() will turn "extra" fields into a list-of-dicts structure for you. I guess it would, because it's separate from the schema. The "Form" validator class claims to do something with partially-validated forms, so that you can run another validator even if the first one finds errors, and pass through the values that did validate successfully. But I've never understood it, so I don't know if it would address your situation. Likewise I've never used ForEach(), so I can only guess how it works. -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en.
