Hi;
I am developing an app suite which requires custom luci pages for licensing and am having problems with section create which always creates a section from defaults. In other words, I cannot have zero sections.
Basically, if there are no section entries in the config file and the create function was not called by the add section button click, I do not want to create the section.
here`s my template (/usr/lib/lua/luci/view/cbi-select-input-add.htm) for addremove section:
<div class="cbi-section-create">
<select class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.select">
<%- for k, v in luci.util.kspairs(self.add_select_options) do %>
<option value="<%=k%>"><%=luci.util.pcdata(v)%></option>
<% end -%>
</select>
<input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" title="<%:Add%>" />
</div>
The CBI maintains a state variable "cbi_state" for the section class which is "add-section" if a section was added or "del-section" if the section was deleted. This is managed by luci javascript.
I have tried to access cbi_state from within the section create function using the following two methods, both of which always return nil:
local cbi_state = luci.http.formvalue( "cbi_state" )
local cbi_state = luci.http.formvalue( luci.cbi.CREATE_PREFIX .. self.config .. "." .. self.sectiontype .. ".cbi_state" )
Questions:
1 - what is the best way (in section create function) to determine if the add and delete section buttons were clicked?
2 - If I am on the right track with cbi_state, how do I access this formvalue from lua?
3 - If cbi_state cannot be accessed, what can I do to the above template to add an on_click handler with a variable that I can access using luci.http.formvalue from within lua?
Thanks;
Bill Ross
(Last edited by rossb on 13 Aug 2016, 17:02)