Mercurial > urweb
annotate tests/crud1.ur @ 341:389399d65331
Crud update form
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 14 Sep 2008 19:03:55 -0400 |
parents | 075b36dbb1a4 |
children | 58eeeb3cbf40 |
rev | line source |
---|---|
adamc@325 | 1 table t1 : {Id : int, A : int, B : string, C : float, D : bool} |
adamc@325 | 2 |
adamc@325 | 3 open Crud.Make(struct |
adamc@339 | 4 con cols :: {(Type * Type)} = [ |
adamc@339 | 5 A = (int, string), |
adamc@339 | 6 B = (string, string), |
adamc@339 | 7 C = (float, string), |
adamc@339 | 8 D = (bool, string) |
adamc@339 | 9 ] |
adamc@339 | 10 |
adamc@325 | 11 val tab = t1 |
adamc@325 | 12 |
adamc@325 | 13 val title = "Crud1" |
adamc@325 | 14 |
adamc@325 | 15 val cols = { |
adamc@339 | 16 A = { |
adamc@339 | 17 Nam = "A", |
adamc@339 | 18 Show = txt _, |
adamc@339 | 19 Widget = fn nm :: Name => <lform><textbox{nm}/></lform>, |
adamc@341 | 20 WidgetPopulated = fn (nm :: Name) n => <lform><textbox{nm} value={show _ n}/></lform>, |
adamc@339 | 21 Parse = readError _, |
adamc@339 | 22 Inject = sql_int |
adamc@339 | 23 }, |
adamc@339 | 24 B = { |
adamc@339 | 25 Nam = "B", |
adamc@339 | 26 Show = txt _, |
adamc@339 | 27 Widget = fn nm :: Name => <lform><textbox{nm}/></lform>, |
adamc@341 | 28 WidgetPopulated = fn (nm :: Name) s => <lform><textbox{nm} value={s}/></lform>, |
adamc@339 | 29 Parse = readError _, |
adamc@339 | 30 Inject = sql_string |
adamc@339 | 31 }, |
adamc@339 | 32 C = { |
adamc@339 | 33 Nam = "C", |
adamc@339 | 34 Show = txt _, |
adamc@339 | 35 Widget = fn nm :: Name => <lform><textbox{nm}/></lform>, |
adamc@341 | 36 WidgetPopulated = fn (nm :: Name) n => <lform><textbox{nm} value={show _ n}/></lform>, |
adamc@339 | 37 Parse = readError _, |
adamc@339 | 38 Inject = sql_float |
adamc@339 | 39 }, |
adamc@339 | 40 D = { |
adamc@339 | 41 Nam = "D", |
adamc@339 | 42 Show = txt _, |
adamc@339 | 43 Widget = fn nm :: Name => <lform><textbox{nm}/></lform>, |
adamc@341 | 44 WidgetPopulated = fn (nm :: Name) b => <lform><textbox{nm} value={show _ b}/></lform>, |
adamc@339 | 45 Parse = readError _, |
adamc@339 | 46 Inject = sql_bool |
adamc@339 | 47 } |
adamc@325 | 48 } |
adamc@325 | 49 end) |