libs/web: support placeholder attribute for comboboxes, fix validation quirks with...
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 9 Aug 2012 11:25:25 +0000 (11:25 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 9 Aug 2012 11:25:25 +0000 (11:25 +0000)
libs/web/htdocs/luci-static/resources/cbi.js
libs/web/luasrc/view/cbi/value.htm

index 655ddbf53a9dede39e3c591cbd03e52a3a09cda7..b07215cbc4728995d00c261386b0caa56ad49a1b 100644 (file)
@@ -441,7 +441,7 @@ function cbi_combobox(id, values, def, man) {
        var obj = document.getElementById(id)
        var sel = document.createElement("select");
                sel.id = selid;
-               sel.className = 'cbi-input-select';
+               sel.className = obj.className.replace(/cbi-input-text/, 'cbi-input-select');
 
        if (obj.nextSibling) {
                obj.parentNode.insertBefore(sel, obj.nextSibling);
@@ -504,6 +504,10 @@ function cbi_combobox(id, values, def, man) {
                        //Do nothing
                }
        })
+
+       // Retrigger validation in select
+       sel.focus();
+       sel.blur();
 }
 
 function cbi_combobox_init(id, values, def, man) {
index 19715a579d685994c175e9770ce367268b9b92cd..d1a7bea5c6a77b96f87fb7eeb9e4cfc52cc0c8a8 100644 (file)
@@ -18,6 +18,8 @@
                -%>
                }, '<%- if not self.rmempty and not self.optional then -%>
                        <%-: -- Please choose -- -%>
+                       <%- elseif self.placeholder then -%>
+                       <%-= pcdata(self.placeholder) -%>
                <%- end -%>', '
                <%- if self.combobox_manual then -%>
                        <%-=self.combobox_manual-%>