template cbi/value.htm implement documented property maxlength
[project/luci.git] / modules / luci-base / luasrc / view / cbi / value.htm
1 <%+cbi/valueheader%>
2         <input type="<%=self.password and 'password" class="cbi-input-password' or 'text" class="cbi-input-text' %>" onchange="cbi_d_update(this.id)"<%=
3                 attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section) or self.default) ..
4                 ifattr(self.size, "size") .. ifattr(self.placeholder, "placeholder") ..
5                 ifattr(self.readonly, "readonly") .. ifattr(self.maxlength, "maxlength")
6         %> />
7         <% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
8         <% if #self.keylist > 0 or self.datatype then -%>
9         <script type="text/javascript">//<![CDATA[
10                 <% if #self.keylist > 0 then -%>
11                 cbi_combobox_init('<%=cbid%>', {
12                 <%-
13                         for i, k in ipairs(self.keylist) do
14                 -%>
15                         <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
16                         <%-if i<#self.keylist then-%>,<%-end-%>
17                 <%-
18                         end
19                 -%>
20                 }, '<%- if not self.rmempty and not self.optional then -%>
21                         <%-: -- Please choose -- -%>
22                         <%- elseif self.placeholder then -%>
23                         <%-= pcdata(self.placeholder) -%>
24                 <%- end -%>', '
25                 <%- if self.combobox_manual then -%>
26                         <%-=self.combobox_manual-%>
27                 <%- else -%>
28                         <%-: -- custom -- -%>
29                 <%- end -%>');
30                 <%- end %>
31                 <% if self.datatype then -%>
32                 cbi_validate_field('<%=cbid%>', <%=tostring((self.optional or self.rmempty) == true)%>, '<%=self.datatype:gsub("'", "\\'")%>');
33                 <%- end %>
34         //]]></script>
35         <% end -%>
36 <%+cbi/valuefooter%>