Martin Fopp ha scritto:
> Hi all, I'm still learining turbogears and after a lots of searching I
> didn't find a solution.
> I've got a form with one autocomplete field. My intention is, that
> after filling the autocomplete field all other fields are populatet
> with the right data. This is my code:
> #controller.py
> class VereinFields(widgets.WidgetsList):
> """ The WidgetsList defines the fields of the form."""
> verein_name = AutoCompleteField(search_controller =
> "ac_search_verein",
> search_param = "input",
> result_name = "matches",
> only_suggest = True,
> take_focus=True)
> name = widgets.TextField(validator=validators.NotEmpty(),
> attrs={'size':45})
> vorname = widgets.TextField(validator=validators.NotEmpty(),
> attrs={'size':45})
> strasse = widgets.TextField(validator=validators.NotEmpty(),
> attrs={'size':45})
> plz = widgets.TextField(validator=validators.Int(not_empty=True),
> attrs={'size':4})
> ort = widgets.TextField(validator=validators.NotEmpty(),
> attrs={'size':45})
> tel = widgets.TextField(validator=validators.NotEmpty(),
> attrs={'size':20})
> email =
> widgets.TextField(validator=validators.Email(not_empty=True),
> attrs={'size':45})
> land = widgets.TextField(validator=validators.NotEmpty(),
> attrs={'size':2})
> ..
> @expose(template="getucupapp_2007.templates.verein_verw")
> def verein_verw(self, tg_errors=None):
> """ page: verein_verw """
> if tg_errors:
> flash('There was a problem with the form!')
> return dict(tt=Verein.select(), form=VEREIN_FORM)
>
> @turbogears.expose(format = "json")
> def ac_search_verein(self, input):
> input = input.lower()
> matches = []
> for verein in Verein.select():
> if verein.verein_name.lower().find(input) > -1:
> matches.append(verein.verein_name)
> return dict(matches = matches)
>
> # verein_verw.kid
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/
> kid/ns#"
> py:extends="'master.kid'">
> <head>
> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"
> py:replace="''"/>
> <title>Test</title>
> </head>
> <body>
> <div class="main_content">
> <h2>TT</h2>
> <p py:content="form(tt[0], submit_text='update')">Comment
> form</p>
> </div>
> </body>
> </html>
>
> How can I achieve this goal?
>
>
>
1) autosubmitter, on some event autosubmit and the server do the work
for you
2) compound widget with ajax
.
The best solution i found is do a compound widget with event-handler
iside, on some event, an ajax call do the qry and fill other fields.
If you want i can send to you my compound widget as an example.
Gla
--
+------------------------------------------------------------+
Glauco Uri - Programmatore
glauco(at)allevatori.com
Sfera Carta Software� [EMAIL PROTECTED]
Via Bazzanese,69 Casalecchio di Reno(BO) - Tel. 051591054
+------------------------------------------------------------+
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---