[luci] formvaluetable() does nothing in my template

Loren Stafford lstafford at ubicom.com
Fri Sep 4 23:07:31 CEST 2009


I am trying to build a form and form handler in a single template (keeping it simple for a documentation example). But formvaluetable() never returns any values, even though a packet sniffer clearly shows appropriately named form values being sent in the POST request.

What did I do wrong? I've tried different values for pfx -- empty and full name of a form value. All do nothing.

I noticed, grepping for other uses of formvaluetable() in LuCI, that it is never used in templates (as I am doing), only in controllers. But, what should I conclude from that?

Here's a stripped-down version of my template:

<%+header%>
<% 
require "luci.http"
require "luci.util"
require "luci.sys"
require "luci.fs"
local pfx = "item_"
local vlines = {} -- Gets filled in from a file; keys are generated with pfx.
%>
<form action="<%=REQUEST_URI%>" method="post">
	<table class="cbi-section-table">
	<% for k,v in pairs(vlines) do for s,f,x in string.gmatch(v,"(%w*)\t(%w+)\t(%w+)") do%>
		<tr class="cbi-section-table-row">
			<td class="cbi-section-table-cell"><%=s%></td>
			<td class="cbi-section-table-cell">
				<label class="cbi-value-title" for="<%=k%>"><%=f%></label></td>
			<td class="cbi-value-field">
				<input class="cbi-input-test" type="text" name="<%=k%>" id="<%=k%>" value="<%=x%>" />
			</td>
		</tr>
	<% end end %>
	</table>	

	<pre><% for k,v in pairs(luci.http.formvaluetable(pfx)) do
			write (k .. ":" .. v .. "\n")
		end %>
	</pre>
</form>
<%+footer%>

Output: nothing.

Loren Stafford
Ubicom, Inc.
Skype: loren.stafford
 



More information about the luci mailing list