Hi all,

I use TG2.1 with forms for which I enjoy validators methods. I especially use forms with select fields for which I use the validator OneOf(...) with a list of allowed values taken from my database. Unfortunately, this list is not static, so the classic way-of-build forms is not taking into account new values.

Here is a sample code:

class AffairAddForm(PapirusForm):
  class fields(PapirusWidgetList):
    site_id = twf.SingleSelectField(
                  validator=twfv.OneOf(pla.getSiteIdList()),
                  label_text="Site",
                )

    affair_label = twf.TextField(
                  validator=twfv.NotEmpty(not_empty=True),
                  label_text="Label",
                )
  submit_text = 'Save Affair'

The function getSiteIdList() returns a list of ids taken from my database. I'd like to build this dynamically, so that if I add a new value in the database, then the OneOf() validator will also accept this new value.

How can I do this ? I looked at the FormEncode and ToscaWidget documentations but didn't find what is the best way to do so.

Thanks in advance.

Damien

--
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