From 2d8bd86c86846c1dc688fbe5039009102d7a74d3 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Wed, 20 May 2015 15:51:39 -0400 Subject: htmlviewfunctions.lua fixes to properly display readonly checkbox and select --- lib/htmlviewfunctions.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/htmlviewfunctions.lua b/lib/htmlviewfunctions.lua index a43bead..3c9f34e 100644 --- a/lib/htmlviewfunctions.lua +++ b/lib/htmlviewfunctions.lua @@ -213,6 +213,7 @@ function mymodule.displayformitem(myitem, name, header_level, group) elseif myitem.type == "boolean" then local tempval = myitem.value if (myitem.value == true) then myitem.checked = "" end + if (myitem.readonly == true) then myitem.disabled = true end myitem.value = "true" io.write(html.form.checkbox(myitem)) myitem.value = tempval @@ -222,7 +223,17 @@ function mymodule.displayformitem(myitem, name, header_level, group) io.write(html.form.longtext(myitem)) myitem.value = tempval elseif myitem.type == "select" and myitem.readonly then + local tempval = myitem.value + if myitem.option and myitem.option[1] and type(myitem.option[1]) == "table" then + for i,o in ipairs(myitem.option) do + if tempval == o.value then + myitem.value = o.label + break + end + end + end io.write((html.form.text(myitem) or "")) + myitem.value = tempval else io.write((html.form[myitem.type](myitem) or "")) end -- cgit v1.2.3