As a a supplement, my hidden fields are structured as such:
<input type="hidden" value="3" name="num_sessions"
id="num_sessions">
<input type="hidden" value="12 Mar 2010 " name="sess-0.date"
id="sess-0.date">
<input type="hidden" value="12:00" name="sess-0.start_time"
id="sess-0.start_time">
<input type="hidden" value="13:00" name="sess-0.end_time"
id="sess-0.end_time">
<input type="hidden" value="TB 236 - Sound Design"
name="sess-0.location" id="sess-0.location">
<input type="hidden" value="5545" name="sess-0.location_id"
id="sess-0.location_id">
<input type="hidden" value="Chris Yeo" name="sess-0.instructor"
id="sess-0.instructor">
<input type="hidden" value="3101" name="sess-0.instructor_id"
id="sess-0.instructor_id">
<input type="hidden" value="fdsfds" name="sess-0.description"
id="sess-0.description">
<input type="hidden" value="13 Mar 2010 " name="sess-1.date"
id="sess-1.date">
<input type="hidden" value="12:00" name="sess-1.start_time"
id="sess-1.start_time">
<input type="hidden" value="13:00" name="sess-1.end_time"
id="sess-1.end_time">
<input type="hidden" value="TB 236 - Sound Design"
name="sess-1.location" id="sess-1.location">
<input type="hidden" value="5545" name="sess-1.location_id"
id="sess-1.location_id">
<input type="hidden" value="Chris Yeo" name="sess-1.instructor"
id="sess-1.instructor">
<input type="hidden" value="3101" name="sess-1.instructor_id"
id="sess-1.instructor_id">
<input type="hidden" value="fdsfds" name="sess-1.description"
id="sess-1.description">
As you can see, this conforms to how FormEncode handles repeating
fields. The hidden inputs were inserted into my form through another
form on the same page.
Now if I set filter_extra_feilds = False, does this mean all of the
above hidden fields will be ignored by the validator? If so, would
this also mean that these field values won't form the field_dictionary
(I'm referring to the self.form_result)?
On Mar 7, 10:36 pm, Mark <[email protected]> wrote:
> 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.