From 3553d308f65a037d7cef2f0c7546db44c23afa14 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 20 Dec 2011 17:52:10 +0000 Subject: [PATCH] [PATCH] Naive fix for bug #208 For SimpleSection, use the section name (always "1") instead of the section type in the CBI-like string used to identify the upload. This allows upload fields to be placed in SimpleSections. The fix changes a minimal number of lines, but does introduce some unnecessary confusion, it may or may not be better than a more thorough/invasive fix. Set the enctype for the form element in the simpleform view to be multipart/form-data because the default application/x-www-form-urlencoded does not support input files. Signed-off-by: Kevin Locke --- libs/web/luasrc/cbi.lua | 6 +++--- libs/web/luasrc/view/cbi/simpleform.htm | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/web/luasrc/cbi.lua b/libs/web/luasrc/cbi.lua index 8b9805f04..ff030a268 100644 --- a/libs/web/luasrc/cbi.lua +++ b/libs/web/luasrc/cbi.lua @@ -102,7 +102,7 @@ function load(cbimap, ...) for _, field in ipairs(map.upload_fields) do uploads[ field.config .. '.' .. - field.section.sectiontype .. '.' .. + (field.section.sectiontype or '1') .. '.' .. field.option ] = true end @@ -124,8 +124,8 @@ function load(cbimap, ...) )() if c and s and o then - local t = uci:get( c, s ) - if t and uploads[c.."."..t.."."..o] then + local t = uci:get( c, s ) or s + if uploads[c.."."..t.."."..o] then local path = upldir .. field.name fd = io.open(path, "w") if fd then diff --git a/libs/web/luasrc/view/cbi/simpleform.htm b/libs/web/luasrc/view/cbi/simpleform.htm index 1a4726a02..f7c9f3324 100644 --- a/libs/web/luasrc/view/cbi/simpleform.htm +++ b/libs/web/luasrc/view/cbi/simpleform.htm @@ -1,5 +1,5 @@ <% if not self.embedded then %> -
+
-- 2.25.1