# HG changeset patch # User Adam Chlipala # Date 1306687471 14400 # Node ID 607657eb28650a9322f61c66baf693e55a8d21cf # Parent c12ceb891350b3ac2e8644157e7b676dd6199635 Properly handle form textboxes that have sources diff -r c12ceb891350 -r 607657eb2865 lib/js/urweb.js --- a/lib/js/urweb.js Sun May 29 12:18:59 2011 -0400 +++ b/lib/js/urweb.js Sun May 29 12:44:31 2011 -0400 @@ -461,7 +461,8 @@ populate(x); } -function input(x, s, recreate, type) { +function input(x, s, recreate, type, name) { + if (name) x.name = name; if (type) x.type = type; x.dead = false; x.signal = ss(s); @@ -473,9 +474,9 @@ return x; } -function inp(s) { +function inp(s, name) { var x = input(document.createElement("input"), s, - function(x) { return function(v) { if (x.value != v) x.value = v; }; }); + function(x) { return function(v) { if (x.value != v) x.value = v; }; }, null, name); x.value = s.data; x.onkeyup = function() { sv(s, x.value) }; diff -r c12ceb891350 -r 607657eb2865 src/monoize.sml --- a/src/monoize.sml Sun May 29 12:18:59 2011 -0400 +++ b/src/monoize.sml Sun May 29 12:44:31 2011 -0400 @@ -2737,8 +2737,8 @@ (L.EFfi ("Basis", "sql_nfunc"), _), _), _), _), _), - _), _), - _) => + _), _), + _) => let val s = (L'.TFfi ("Basis", "string"), loc) fun sc s = (L'.EPrim (Prim.String s), loc) @@ -3258,7 +3258,9 @@ | SOME (_, src, _) => (strcat [str ""], + str "), \"", + str name, + str "\")"], fm)) | _ => (Print.prefaces "Targs" (map (fn t => ("T", CorePrint.p_con env t)) targs); raise Fail "No name passed to textbox tag")) diff -r c12ceb891350 -r 607657eb2865 tests/tsource.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/tsource.ur Sun May 29 12:44:31 2011 -0400 @@ -0,0 +1,28 @@ +fun doSubmit r = + return Done {[readError r.Amount1 * readError r.Amount2 * 2.0]} + +fun main () = + amount1S <- source "1"; + amount2S <- source "1"; + return +
+ + + + +
Amount1:
Amount2:
Total:
+ + + +
+ +and showTotal amount1S amount2S = + a1 <- signal amount1S; + a2 <- signal amount2S; + return (case ((read a1), (read a2)) of + (None, _) => + | (_, None) => + | (Some a, Some b) => {[a * b * 2.0]}) diff -r c12ceb891350 -r 607657eb2865 tests/tsource.urs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/tsource.urs Sun May 29 12:44:31 2011 -0400 @@ -0,0 +1,1 @@ +val main : unit -> transaction page