Working out of the 1.0 branch...

In the turbogears/widgets/static/ajax.js, remoteFormRequest does not
play nicely with submitting values from CheckBoxList widgets.

The problem is, all of the checkboxes have the same name.  It looks
like line 9 might be the biggest source of the problem, and in general
the use of a dictionary (or whatever it's called in JS, I'm not a JS
guru myself).

Say I have a form with this Checkbox widget:

  CheckBoxList(name='foo', options=[(1, 'One'), (2, 'Two'), (3,
'Three')])

The controller is decorated with:

  @expose(fragment=True)
  @validate(validators=dict(foo=validators.Set()))
  def process(self, foo=None):
      print foo
      # ...

When the RemoteForm containing the CheckBoxList widget is submitted, it
uses the remoteFormRequest JS function to do so.

Let's say you clicked  1 and 2.

What you get back in foo in the process method of the controller is
['3'].  After peeking under the hood using Firebug (wonderful Firefox
extension!!) it is actually submitting this as the POST data:

 foo=3&tg_random=1148485489989

This is because remoteFormRequest just looks at the fact that it's an
INPUT tag, gets the name, gets the value, and stuffs it into a
dictionary.

What it should probably do is see that it's an INPUT tag, see that it's
of the "checkbox" type, then see if "checked" is set or not.  If it is,
it should add the name/value pair to a list, rather than a dictionary.
When it hands it off to remoteRequest, remoteRequest in turn passes it
to queryString.

I may have my terminology all wrong but I am going to charge forward
and see if I can get a patch ready for remoteFormRequest that will do
what I need it to do.  I'll post it here when I'm done.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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-trunk
-~----------~----~----~----~------~----~------~--~---

Reply via email to