json form and checkboxes

319 views
Skip to first unread message

edgarchan

unread,
Dec 3, 2009, 4:33:43 PM12/3/09
to Lift
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="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</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="submit">Submit</button>
</lift:JSONForm.show>



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

John Goodsen

unread,
Dec 3, 2009, 4:49:00 PM12/3/09
to lif...@googlegroups.com
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
jgoo...@radsoft.com            Lean/Agile/XP/Scrum Coaching and Training
http://www.radsoft.com             Ruby/Rails, Scala/Lift 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 lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.





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

David Pollak

unread,
Dec 3, 2009, 6:45:47 PM12/3/09
to lif...@googlegroups.com
Yeah... this is a bug in the way we serialize the form.  Please open a ticket at http://github.com/dpp/liftweb/issues

--

You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@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
Reply all
Reply to author
Forward
0 new messages