changeset 1692:a1a1d66aebac

Change <radio> to yield [option string]
author Adam Chlipala <adam@chlipala.net>
date Sat, 10 Mar 2012 12:53:33 -0500
parents ea292bf9431f
children 27d68ccb2c9e
files lib/ur/basis.urs src/cjr_print.sml tests/radio.ur tests/radio.urs
diffstat 4 files changed, 27 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ur/basis.urs	Sat Mar 03 16:41:20 2012 -0500
+++ b/lib/ur/basis.urs	Sat Mar 10 12:53:33 2012 -0500
@@ -830,7 +830,7 @@
 val postData : postBody -> string
 
 con radio = [Body, Radio]
-val radio : formTag string radio [Id = id]
+val radio : formTag (option string) radio [Id = id]
 val radioOption : unit -> tag ([Value = string, Checked = bool] ++ boxAttrs) radio [] [] []
 
 con select = [Select]
--- a/src/cjr_print.sml	Sat Mar 03 16:41:20 2012 -0500
+++ b/src/cjr_print.sml	Sat Mar 10 12:53:33 2012 -0500
@@ -1,4 +1,4 @@
-(* Copyright (c) 2008-2011, Adam Chlipala
+(* Copyright (c) 2008-2012, Adam Chlipala
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -2868,6 +2868,16 @@
                                   string "}}",
                                   newline]
                          end
+                       | TOption _ =>
+                         box [string "uw_input_",
+                              p_ident x,
+                              space,
+                              string "=",
+                              space,
+                              string "uw_get_input(ctx, ",
+                              string (Int.toString n),
+                              string ");",
+                              newline]
                        | _ =>
                          box [string "request = uw_get_",
                               string f,
--- a/tests/radio.ur	Sat Mar 03 16:41:20 2012 -0500
+++ b/tests/radio.ur	Sat Mar 10 12:53:33 2012 -0500
@@ -1,13 +1,15 @@
-val handler = fn x => <html><body>
-        You entered: {cdata x.A}
-</body></html>
+fun handler x = return <xml><body>
+  You entered: {[case x.A of
+                     None => "nothing at all"
+                   | Some v => v]}
+</body></xml>
 
-val main = fn () => <html><body>
-        <lform>
-                <radio{#A}>
-                        <li> <radioOption value="A"/>A</li>
-                        <li> <radioOption value="B"/>B</li>
-                </radio>
-                <submit action={handler}/>
-        </lform>
-</body></html>
+fun main () = return <xml><body>
+  <form>
+    <radio{#A}>
+      <li><radioOption value="A"/>A</li>
+      <li><radioOption value="B"/>B</li>
+    </radio>
+    <submit action={handler}/>
+  </form>
+</body></xml>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/radio.urs	Sat Mar 10 12:53:33 2012 -0500
@@ -0,0 +1,1 @@
+val main : unit -> transaction page