projects
/
oweals
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a8c64ef
)
libs/cbi: Catch errors while creating named sections
author
Steven Barth
<steven@midlink.org>
Sun, 7 Sep 2008 21:22:39 +0000
(21:22 +0000)
committer
Steven Barth
<steven@midlink.org>
Sun, 7 Sep 2008 21:22:39 +0000
(21:22 +0000)
libs/cbi/luasrc/cbi.lua
patch
|
blob
|
history
libs/cbi/luasrc/view/cbi/tblsection.htm
patch
|
blob
|
history
libs/cbi/luasrc/view/cbi/tsection.htm
patch
|
blob
|
history
modules/admin-full/luasrc/model/cbi/admin_network/network.lua
patch
|
blob
|
history
diff --git
a/libs/cbi/luasrc/cbi.lua
b/libs/cbi/luasrc/cbi.lua
index a37e81e871ac24779d93f0a11e3bb2e09fb79337..3e72097814813f8c9da3b2ac66c30f2f64dd149a 100644
(file)
--- 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
local stat
if section then
- stat = self.map:set(section, nil, self.sectiontype)
+ stat = se
ction:match("^%w+$") and se
lf.map:set(section, nil, self.sectiontype)
else
section = self.map:add(self.sectiontype)
stat = section
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 name and #name > 0 then
created = self:create(name) and name
+ if not created then
+ self.invalid_cts = true
+ end
end
end
end
end
end
end
diff --git
a/libs/cbi/luasrc/view/cbi/tblsection.htm
b/libs/cbi/luasrc/view/cbi/tblsection.htm
index 49930f84828dbe57abc76dc8129f6b2b6060dcfc..be7e723f7a5b41c99fc76378f32bb946120e8812 100644
(file)
--- 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.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%>" />
<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>
<% end %>
</div>
</td>
diff --git
a/libs/cbi/luasrc/view/cbi/tsection.htm
b/libs/cbi/luasrc/view/cbi/tsection.htm
index 33d5c8e499b6bf5fff0e758d0f59368a3f1974db..70c44aaf6b5e16f283a02998fc20081f6dc18866 100644
(file)
--- 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.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%>" />
<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 %>
<%- end %>
</div>
<%- end %>
diff --git
a/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
b/modules/admin-full/luasrc/model/cbi/admin_network/network.lua
index fce84fe3f40332e29426f2bb70919021259472d1..dab4bb873a63a9e83ee26b1ff79822c030701940 100644
(file)
--- a/
modules/admin-full/luasrc/model/cbi/admin_network/network.lua
+++ b/
modules/admin-full/luasrc/model/cbi/admin_network/network.lua
@@
-33,6
+33,8
@@
end
function s.create(self, section)
if TypedSection.create(self, section) then
created = section
function s.create(self, section)
if TypedSection.create(self, section) then
created = section
+ else
+ self.invalid_cts = true
end
end
end
end