At 11:05 PM 27/06/2004 -0400, CLIFFORD ILKAY wrote:
Hi,

I am trying to bind the results of a database query to a FormKit SelectField. Here is my code:

################
newForm.addField(Fields.SelectField('groupType',label="Group Type"))

# 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:
        newForm.groupType.addChoice(theGroupType.id,theGroupType.description)
################

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.


newForm.groupType.clearChoices()

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.

newForm.groupType.addChoice(0,None)

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.

Regards,

Clifford Ilkay
Dinamis Corporation
3266 Yonge Street, Suite 1419
Toronto, Ontario
Canada M4N 3P6

Tel: 416-410-3326



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to