diff demo/subforms.ur @ 780:0084af7af35a

subforms demo
author Adam Chlipala <adamc@hcoop.net>
date Sun, 03 May 2009 15:53:29 -0400
parents
children be0c4e2e488a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/subforms.ur	Sun May 03 15:53:29 2009 -0400
@@ -0,0 +1,43 @@
+fun sub r =
+    let
+        fun sub' ls =
+            case ls of
+                [] => <xml/>
+              | r :: ls => <xml>
+                <li>{[r.Num]} = {[r.Text]}</li>
+                {sub' ls}
+              </xml>
+    in
+        return <xml><body>
+          {sub' r.Lines}
+        </body></xml>
+    end
+
+fun subforms n =
+    if n <= 0 then
+        <xml/>
+    else
+        <xml>
+          <entry>
+            <hidden{#Num} value={show n}/>
+            <li>{[n]}: <textbox{#Text}/></li>
+          </entry>
+          {subforms (n - 1)}
+        </xml>
+
+fun form n = return <xml><body>
+  <form>
+    <subforms{#Lines}>
+      {subforms n}
+    </subforms>
+    <submit action={sub}/>
+  </form>
+
+  <a link={form (n + 1)}>One more blank</a><br/>
+  {if n > 0 then
+       <xml><a link={form (n - 1)}>One fewer blank</a></xml>
+   else
+       <xml/>}
+</body></xml>
+
+fun main () = form 1