From b9926ecbe8279f60d7dfe7648c7c0851cb0aaabc Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 27 Oct 2014 22:06:26 +0000 Subject: Add code to determine the primary key fields and use them to uniquely identify rows Previously, this assumed 'id' was the primary key column as inherited from the kamailio code --- db-viewtable-html.lsp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'db-viewtable-html.lsp') diff --git a/db-viewtable-html.lsp b/db-viewtable-html.lsp index 283d624..3bde35e 100644 --- a/db-viewtable-html.lsp +++ b/db-viewtable-html.lsp @@ -65,9 +65,9 @@ if form.value.connection then formvalues.connection = form.value.connection for n,v in pairs(form.value.connection.value) do v.type="hidden" end end -if form.value.fields then +if form.value.keyfields then formvalues.fields = cfe({ type="group", value={} }) - for i,f in ipairs(form.value.fields.value) do + for i,f in ipairs(form.value.keyfields.value) do formvalues.fields.value[f] = cfe({ type="hidden" }) end end @@ -78,7 +78,13 @@ formvalues.redir = redir <% for i,tableentry in ipairs(form.value.entries.value) do %> <% if viewlibrary.check_permission("deletetableentry") or viewlibrary.check_permission("updatetableentry") then %> - <% formvalues.fields.value.id.value = tableentry.id %> + <% + if formvalues.fields then + for i,f in ipairs(form.value.keyfields.value) do + formvalues.fields.value[f].value = tableentry[f] + end + end + %> <% if viewlibrary.check_permission("updatetableentry") then %> <% htmlviewfunctions.displayitem(cfe({type="link", value=formvalues, label="", option="Update", action="updatetableentry"}), page_info, -1) %> -- cgit v1.2.3