diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/crud2.ur	Thu Oct 23 18:45:10 2008 -0400
@@ -0,0 +1,34 @@
+table t : {Id : int, Nam : string, Ready : bool}
+
+open Crud.Make(struct
+                   val tab = t
+                             
+                   val title = "Are you ready?"
+
+                   val cols = {Nam = Crud.string "Name",
+                               Ready = {Nam = "Ready",
+                                        Show = (fn b => if b then
+                                                            <xml>Ready!</xml>
+                                                        else
+                                                            <xml>Not ready</xml>),
+                                        Widget = (fn (nm :: Name) => <xml>
+                                          <select{nm}>
+                                            <option>Ready</option>
+                                            <option>Not ready</option>
+                                          </select>
+                                        </xml>),
+                                        WidgetPopulated = (fn (nm :: Name) b => <xml>
+                                          <select{nm}>
+                                            <option selected={b}>Ready</option>
+                                            <option selected={not b}>Not ready</option>
+                                          </select>
+                                        </xml>),
+                                        Parse = (fn s =>
+                                                    case s of
+                                                        "Ready" => True
+                                                      | "Not ready" => False
+                                                      | _ => error <xml>Invalid ready/not ready</xml>),
+                                        Inject = _
+                                       }
+                              }
+               end)