[Lift] json form and checkboxes

2009-12-03 Thread edgarchan
Hi

i tried the json form tutorial (HowTo_use_JSON_forms) and everything
was ok until i put some checkboxes ... the thing is that no matter how
many of them i check only one is being send to the server.

example

lift:JSONForm.show
input type=text name=name /
br /
input type=text name=value /
br /
input type=radio name=vehicle value=Bike /
input type=radio name=vehicle value=Car /
input type=radio name=vehicle value=Airplane /
br /
select name=cars
option value=volvoVolvo/option
option value=saabSaab/option
option value=opelOpel/option
option value=audiAudi/option
/select
br /
Soccer: input type=checkbox name=sports 
value=soccer  /
br /
Football: input type=checkbox name=sports 
value=football  /
br /
Baseball: input type=checkbox name=sports 
value=baseball  /
br /
Basketball: input type=checkbox name=sports
value=basketball  /
button type=submitSubmit/button
/lift:JSONForm.show



apparently it has to do with the way the formToJSON function creates
the object
im using 1.1-snapshot

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] json form and checkboxes

2009-12-03 Thread John Goodsen
Use the SHtml.checkbox to generate your checkboxes:  From the ExploringLift
book:

The checkbox method generates a checkbox form element, taking an initial
Boolean value as well as a function ( Boolean) = Any that is called when the
checkbox is submitted. If you've done a lot of HTML form processing you
might wonder how this actually occurs, since an unchecked checkbox is not
actually submitted as part of a form. Lift works around this by adding a
hidden form element for each checkbox with the same element name, but with a
false value, to ensure that the callback function is always called.

-- 
John Goodsen RADSoft / Better Software Faster
jgood...@radsoft.comLean/Agile/XP/Scrum Coaching and Training
http://www.radsoft.com Ruby/Rails, Scala/Lift and Java Solutions


On Thu, Dec 3, 2009 at 4:33 PM, edgarchan edgarchancarri...@gmail.comwrote:

 Hi

 i tried the json form tutorial (HowTo_use_JSON_forms) and everything
 was ok until i put some checkboxes ... the thing is that no matter how
 many of them i check only one is being send to the server.

 example

lift:JSONForm.show
input type=text name=name /
br /
input type=text name=value /
br /
input type=radio name=vehicle value=Bike /
input type=radio name=vehicle value=Car /
input type=radio name=vehicle value=Airplane /
br /
select name=cars
option value=volvoVolvo/option
option value=saabSaab/option
option value=opelOpel/option
option value=audiAudi/option
/select
br /
Soccer: input type=checkbox name=sports
 value=soccer  /
 br /
Football: input type=checkbox
 name=sports value=football  /
 br /
Baseball: input type=checkbox
 name=sports value=baseball  /
 br /
Basketball: input type=checkbox
 name=sports
 value=basketball  /
button type=submitSubmit/button
/lift:JSONForm.show



 apparently it has to do with the way the formToJSON function creates
 the object
 im using 1.1-snapshot

 --

 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.





-- 
John Goodsen RADSoft / Better Software Faster
jgood...@radsoft.comLean/Agile/XP/Scrum Coaching and Training
http://www.radsoft.com  Ruby on Rails and Java Solutions

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] json form and checkboxes

2009-12-03 Thread David Pollak
Yeah... this is a bug in the way we serialize the form.  Please open a
ticket at http://github.com/dpp/liftweb/issues

On Thu, Dec 3, 2009 at 1:33 PM, edgarchan edgarchancarri...@gmail.comwrote:

 Hi

 i tried the json form tutorial (HowTo_use_JSON_forms) and everything
 was ok until i put some checkboxes ... the thing is that no matter how
 many of them i check only one is being send to the server.

 example

lift:JSONForm.show
input type=text name=name /
br /
input type=text name=value /
br /
input type=radio name=vehicle value=Bike /
input type=radio name=vehicle value=Car /
input type=radio name=vehicle value=Airplane /
br /
select name=cars
option value=volvoVolvo/option
option value=saabSaab/option
option value=opelOpel/option
option value=audiAudi/option
/select
br /
Soccer: input type=checkbox name=sports
 value=soccer  /
 br /
Football: input type=checkbox
 name=sports value=football  /
 br /
Baseball: input type=checkbox
 name=sports value=baseball  /
 br /
Basketball: input type=checkbox
 name=sports
 value=basketball  /
button type=submitSubmit/button
/lift:JSONForm.show



 apparently it has to do with the way the formToJSON function creates
 the object
 im using 1.1-snapshot

 --

 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.





-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[Lift] JSON form with

2009-07-30 Thread James Kearney

I think the current implementation of the JSON form is broken.

If you put an  in a text field and try to submit it via a JSON form
it doesn't get handled correctly.

To be precise the formToJSON function in jlift.js doesn't work, and
again to be more precise the params method is broken / not fit for
purpose.

The params method (line 249) calls s.join() and then returns but it
doesn't escape the  character (it also uses = but doesn't escape
that). If the params function does what I think it is supposed to do
which is split paramters for a URL then it should really call
encodeURI on the values.

That aside I don't think the formToJSON function should be using the
param function. It gets a JSON object from jQuery serializeArray makes
it into a string split by  and = then goes and splits based on  and
= again building up some JSON (as a string) then parses the JSON. Why
not operate on the JSON from jQuery from the start.
e.g.

formToJSON : function(formId)
   {
   json = jQuery(# + formId).serializeArray();
   ret = {}

   for (var i in json)
   {
   var obj = json[i]

   ret[obj.name] = obj.value
   }

   return ret;
   }

This does work differently from before since it won't call functions
like params does but I don't think jQuery's serializeArray puts
functions in the object it returns so that is not needed.


James

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---