summaryrefslogtreecommitdiff
path: root/demo/subforms.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-05-03 15:53:29 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-05-03 15:53:29 -0400
commitf159f01dfe249107a630833d58af9582f8fcc4ec (patch)
treef4acd8b809a91acc1677dcafcd4f65e3479ec643 /demo/subforms.ur
parent2174aa160c931821b2d4d841266bc1843774200f (diff)
subforms demo
Diffstat (limited to 'demo/subforms.ur')
-rw-r--r--demo/subforms.ur43
1 files changed, 43 insertions, 0 deletions
diff --git a/demo/subforms.ur b/demo/subforms.ur
new file mode 100644
index 00000000..71bd1e82
--- /dev/null
+++ b/demo/subforms.ur
@@ -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