I have multiple similar forms on the same page with different names
that submit to the same method.  The method is decorated like this:

    @expose()
    @validate(form=_getCurrentPhotoForm)
    @error_handler(photos)
    def save_photo(self, complex, photo, model_photo,
                   is_primary=None,
                   photo_comments=None):


where _getCurrentPhotoForm figures out which form was submitted,
creates that form, sets cherrypy.request.validated_form and returns
the form.  When the error_handler, "photos", is called, it checks
cherrypy.request.validated_form.name and substitutes the validated
form for the form with the same name sent to the template, so that one
of the forms sent to the template is the same instance of the
validated_form.

The problem is that the field errors print on every form, not just on
the one that was submitted.  Is there something wrong with my form
template maybe?  I put it below so it doesn't clutter this post up too
much.

    <div xmlns:py="http://purl.org/kid/ns#"; style="text-align: left;">
    <form
        name="${name}"
        action="${action}"
        method="${method}"
        class="photo_form"
        py:attrs="form_attrs"
    >
        <div py:for="field in hidden_fields"
            py:replace="field.display(value_for(field),
**params_for(field))"
        />
        <a
        py:if="photo_id"
        href="${tg.url('delete_photo', photo_id=photo_id)}">
        Delete this photo.
        </a>
        <img src="${thumb_url}" py:if="photo_id"
             alt="complex or unit model photo"
             style="float:left; padding-right: 1.2em;" />
        <ul>
            <li py:for="field in map(field_for, ['photo',
'is_primary', 'model_photo', 'photo_comments'])">
                <label class="fieldlabel"
                       for="field.field_id"
                       py:content="field.label" />
                <span py:replace="field.display(value_for(field),
                      **params_for(field))" />
                <span py:if="field.error"
                      class="fielderror"
                      py:content="field.error"/>
                <span py:if="field.help_text" class="fieldhelp"
                      py:content="field.help_text" />
            </li>
            <li>
                <input type="submit" class="submitbutton"
                value="${submit_text}"
                />
            </li>
        </ul>
    </form>
    </div>

Randall


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to