I'm sorry guys, maybe it's just me, but I'm having tons of problems
with my forms:

I have a new() and create() just like what the book says.  My new()
action basically just renders my form.  My create() action is as such:

@validate(schema=NewClassForm(), form='new', post_only=True,
on_get=True, auto_error_formatter=custom_formatter)
    def create(self):
        """
        Add a new class with sessions and save it to the database
        """

My Schema is the following:

class NewClassForm(formencode.Schema):
    allow_extra_fields = True
    filter_extra_fields = True
    pdb.set_trace()
    pre_validators = [variabledecode.NestedVariables()]
    course = SelectIntCourseValidator(not_empty=True) ...etc.


As stated in my previous posts, I have a form with some HIDDEN input
fields.  I created a ForEach() and all of the Repeating Fields stuff
for the hidden input fields.

When I submit my form (using POST), the new() action is always
run....instead of create().  This must mean there's something wrong
with my form right?

Can someone help me out with this?  What's going on?  Why do I always
get redirected to my new() action?  How do I debug this?  I tried
placing pdb.set_trace() in my Schema, but it never seems to get run at
all.

On Mar 5, 7:04 pm, Mike Orr <[email protected]> wrote:
> 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.

Reply via email to