From: Jo-Philipp Wich Date: Mon, 16 Jul 2018 15:28:50 +0000 (+0200) Subject: luci-base: fix field section add button/input field names X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4da137e8928f936bcab30104d74e4d77d6e64629;p=oweals%2Fluci.git luci-base: fix field section add button/input field names Some CBI map models, mainly the Network -> VLAN page, expect a valid previous section ID in their Section:create() callback. Previous refactoring of the tblsection markup broke this behaviour as the "section" loop variable was accidentally localized, causing it to be undefined outside of the loop body which caused the section add button and name input fields to get rendered with a wrong "name" attribute. Fix this by moving the "section" variable declaration out of the loop and by readding references to it in the non-anonymous section add case. Fixes FS#1657 Fixes 002c4d1d5 ("luci-base: add "Name" label to autogenerated title column") Signed-off-by: Jo-Philipp Wich (cherry picked from commit fcc9cd6a9ab0bd7eaff6b3f3b4dd96fa31f79ebb) --- diff --git a/modules/luci-base/luasrc/view/cbi/tblsection.htm b/modules/luci-base/luasrc/view/cbi/tblsection.htm index c6e4d7e9a..7067aa587 100644 --- a/modules/luci-base/luasrc/view/cbi/tblsection.htm +++ b/modules/luci-base/luasrc/view/cbi/tblsection.htm @@ -55,11 +55,11 @@ local titlename = ifattr(not self.anonymous or self.sectiontitle, "data-title",
<%- end -%> - <%- local isempty, i, k = true, nil, nil + <%- local isempty, section, i, k = true, nil, nil for i, k in ipairs(self:cfgsections()) do isempty = false + section = k - local section = k local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k) local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname) local colorclass = (self.extedit or self.rowcolors) and " cbi-rowstyle-%d" % rowstyle() or "" @@ -126,7 +126,7 @@ local titlename = ifattr(not self.anonymous or self.sectiontitle, "data-title",
<%:Invalid%>
<%- end %>
- +
<% end %>