Hi together,

I'm currently working on a project and stumbled upon a problem that
seems quite common to me, but i cant find a solution to it, so i hoped
you could give me a little help.

I got a form with several fields. One of them is an autocomplete-
field, which displays entries that are loaded from a database. Lets
say the database-table got a column 'id' and a column 'value'. Now i
want to display the values, but save the id in another table (as
reference).

My current idea was to load the value referenced by the id, put it
into the autocomplete-field (not by the validator, but by hand in the
controller) and if the user edits it, the validator should check if
the new value is valid (has an entry in the table) and replace it with
the id, before passing it to the save-method.
The problem with this approach is, that either turbo-gears or
formencode calls to_python and then from_python during the first
display of the form, so i cant convert the data there, unless i would
first convert the value to an id and then convert it back again, just
to have the value i had from the beginning. During the validation only
to_python is called however.

So, in short, i want:
id to value (if form is first displayed, so user doesnt get to see the
id)
value to id (if the form is submitted and the id should be saved to
the database)

Is there any better/simpler way to achieve what i want to do?


Thanks very much,
Daishy

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