Mercurial > urweb
changeset 154:e2b185379592
HTML select
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 24 Jul 2008 11:16:54 -0400 |
parents | cfe6f9db74aa |
children | 4334bb734187 |
files | lib/basis.lig src/monoize.sml tests/select.lac |
diffstat | 3 files changed, 31 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/basis.lig Thu Jul 24 11:10:23 2008 -0400 +++ b/lib/basis.lig Thu Jul 24 11:16:54 2008 -0400 @@ -72,6 +72,10 @@ val radio : lformTag string radio [] val radioOption : unit -> tag [Value = string] radio [] [] [] +con select = [Select] +val lselect : lformTag string select [] +val loption : unit -> tag [Value = string] select [] [] [] + val submit : ctx ::: {Unit} -> [LForm] ~ ctx -> use ::: {Type} -> unit -> tag [Action = $use -> page] ([LForm] ++ ctx) ([LForm] ++ ctx) use []
--- a/src/monoize.sml Thu Jul 24 11:10:23 2008 -0400 +++ b/src/monoize.sml Thu Jul 24 11:16:54 2008 -0400 @@ -329,6 +329,20 @@ normal ("input", SOME (L'.EPrim (Prim.String (" type=\"radio\" name=\"" ^ name ^ "\"")), loc))) + | "lselect" => + (case targs of + [_, (L.CName name, _)] => + (L'.EStrcat ((L'.EStrcat (tagStart "select", + (L'.EPrim (Prim.String (" name=\"" ^ name ^ "\">")), loc)), loc), + (L'.EStrcat (monoExp (env, st) xml, + (L'.EPrim (Prim.String "</select>"), + loc)), loc)), + loc) + | _ => (Print.prefaces "Targs" (map (fn t => ("T", CorePrint.p_con env t)) targs); + raise Fail "No name passed to lselect tag")) + + | "loption" => normal ("option", NONE) + | _ => normal (tag, NONE) end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/select.lac Thu Jul 24 11:16:54 2008 -0400 @@ -0,0 +1,13 @@ +val handler = fn x => <html><body> + You entered: {cdata x.A} +</body></html> + +val main = fn () => <html><body> + <lform> + <lselect{#A}> + <loption value="A">A</loption> + <loption value="B">B</loption> + </lselect> + <submit action={handler}/> + </lform> +</body></html>