On Jun 7, 2:55 pm, "Diez B. Roggisch" <[email protected]> wrote:
> > I've got a pair of tw.forms that are children of a custom widget. All
> > the widgets are named, so the resulting fields have names like
> > "person_form.firstname", etc. I can pass data to the forms at
> > instantiation time (although using unqualified names like "firstname",
>
> This sounds suspicious. What do you mean by instantiation time?
>
Sorry, in the template itself, not when the widget is actually
instantiated. The widget is passed to the template through
templ_context, which I understand is the current accepted method for
non-data objects. In the template the widget is realized like
tmpl_context.my_compound(dict(person_form=dict(firstname=firstname...
etc.
> > rather than "person_form.firstname"), but the kwargs dict passed to
> > the controller contains keys as "person_form.firstname", etc.
>
> > This isn't a problem, although it seems a little counter intuitive,
> > until I add validators... at which time the validators begin to fail
> > with errors like "The input field 'person_form' was not expected.",
> > which I suspect is directly related to the name mangling going on with
> > the child/parent widget relationships.
>
> How exactly do you add validators to the mix?
class PersonForm(TableForm):
show_error = True
fields = [
TextField('firstname', validator=NotEmpty, label_text='First
Name:', show_error=True),
TextField('lastname', validator=NotEmpty(msg="test"),
label_text='Last Name:'),
TextField('phone', validator=NotEmpty, label_text='Phone:'),
#FIXME: Validator for Phone
HiddenField('method'),
HiddenField('term'),
]
submit_text='Add Person'
Then add @validate(form=pform, error_handler=...) to the appropriate
controller methods.
>
> Diez
--
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.