At 11:05 PM 27/06/2004 -0400, CLIFFORD ILKAY wrote:
>I am trying to bind the results of a database query to a FormKit
>SelectField. Here is my code:
># get group types using a SQLObject select() method
>groupTypes = GrpType.select(orderBy=GrpType.q.description)
>pr('''\t<tr><td>%s</td>''' % newForm.groupType.label())
>pr('''\t<td>%s</td></tr>''' % newForm.groupType.tag())
>for theGroupType in groupTypes:
>The select field renders but there is no data in the field. I can print
>theGroupType.id and theGroupType.description to an HTML table without a
>problem so I know I have data. What am I missing?
I have this working but not reliably. I had to add the following line
before the for loop.
Before adding the line above, the first time the form was drawn, the select
list would be empty. If I reloaded the page, I would get an error that the
value x was already in the list. As soon as I added the line, the first
time I loaded the form, the select list was empty again. Subsequent times,
it was loaded properly. I'm not sure what is causing that.
I also added a blank line at the beginning of the select list so that the
first line would not be selected. Of course now I have to trap for the
error because "0" is not a valid group type. It was just put in there as a
place holder for the first line.
Now, if only IE were not broken so that users could navigate select lists
using "type ahead". It works on Firefox on both Windows and Linux and
Konqueror on Linux. As keys are pressed, the selection homes in the choice.
With IE, every keypress is treated as if it were the first one so it
bounces around. Pretty useless really. Any ideas of how to deal with this,
short of having the users not use IE? They want to avoid using a mouse to
navigate forms as much as possible.
3266 Yonge Street, Suite 1419
Canada M4N 3P6