comparison demo/crud2.ur @ 422:0ce90d4d9ae7

Crud2 demo
author Adam Chlipala <adamc@hcoop.net>
date Thu, 23 Oct 2008 18:45:10 -0400
parents
children 6c4643880df5
comparison
equal deleted inserted replaced
421:0767d7ad0c3a 422:0ce90d4d9ae7
1 table t : {Id : int, Nam : string, Ready : bool}
2
3 open Crud.Make(struct
4 val tab = t
5
6 val title = "Are you ready?"
7
8 val cols = {Nam = Crud.string "Name",
9 Ready = {Nam = "Ready",
10 Show = (fn b => if b then
11 <xml>Ready!</xml>
12 else
13 <xml>Not ready</xml>),
14 Widget = (fn (nm :: Name) => <xml>
15 <select{nm}>
16 <option>Ready</option>
17 <option>Not ready</option>
18 </select>
19 </xml>),
20 WidgetPopulated = (fn (nm :: Name) b => <xml>
21 <select{nm}>
22 <option selected={b}>Ready</option>
23 <option selected={not b}>Not ready</option>
24 </select>
25 </xml>),
26 Parse = (fn s =>
27 case s of
28 "Ready" => True
29 | "Not ready" => False
30 | _ => error <xml>Invalid ready/not ready</xml>),
31 Inject = _
32 }
33 }
34 end)