diff options
author | Steven Barth <steven@midlink.org> | 2008-09-07 21:22:39 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-09-07 21:22:39 +0000 |
commit | d8282d382bc675eb1c930eed0fe65c41050400b8 (patch) | |
tree | 8a66bd056d4e92b31366dbe70f96b0d29481919c /libs | |
parent | a8c64ef3b09e8d64ae1c0497b9b852a0d98fdf64 (diff) |
libs/cbi: Catch errors while creating named sections
Diffstat (limited to 'libs')
-rw-r--r-- | libs/cbi/luasrc/cbi.lua | 5 | ||||
-rw-r--r-- | libs/cbi/luasrc/view/cbi/tblsection.htm | 4 | ||||
-rw-r--r-- | libs/cbi/luasrc/view/cbi/tsection.htm | 4 |
3 files changed, 12 insertions, 1 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index a37e81e871..3e72097814 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -566,7 +566,7 @@ function AbstractSection.create(self, section) local stat if section then - stat = self.map:set(section, nil, self.sectiontype) + stat = section:match("^%w+$") and self.map:set(section, nil, self.sectiontype) else section = self.map:add(self.sectiontype) stat = section @@ -795,6 +795,9 @@ function TypedSection.parse(self, novld) if name and #name > 0 then created = self:create(name) and name + if not created then + self.invalid_cts = true + end end end end diff --git a/libs/cbi/luasrc/view/cbi/tblsection.htm b/libs/cbi/luasrc/view/cbi/tblsection.htm index 49930f8482..be7e723f7a 100644 --- a/libs/cbi/luasrc/view/cbi/tblsection.htm +++ b/libs/cbi/luasrc/view/cbi/tblsection.htm @@ -113,8 +113,12 @@ end <% if self.anonymous then %> <input class="cbi-button cbi-button-add" type="submit" value="<%:cbi_add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:cbi_add%>" /> <% else %> + <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %> <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" /> <input class="cbi-button cbi-button-add" type="submit" value="<%:cbi_add%>" title="<%:cbi_add%>" /> + <% if self.invalid_cts then -%> + <br /><%:cbi_invalid%></div> + <%- end %> <% end %> </div> </td> diff --git a/libs/cbi/luasrc/view/cbi/tsection.htm b/libs/cbi/luasrc/view/cbi/tsection.htm index 33d5c8e499..70c44aaf6b 100644 --- a/libs/cbi/luasrc/view/cbi/tsection.htm +++ b/libs/cbi/luasrc/view/cbi/tsection.htm @@ -45,8 +45,12 @@ $Id$ <% if self.anonymous then -%> <input type="submit" class="cbi-button cbi-button-add" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" value="<%:cbi_add%>" /> <%- else -%> + <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %> <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" /> <input type="submit" class="cbi-button cbi-button-add" value="<%:cbi_add%>" /> + <% if self.invalid_cts then -%> + <br /><%:cbi_invalid%></div> + <%- end %> <%- end %> </div> <%- end %> |