From: Jo-Philipp Wich Date: Thu, 9 Aug 2012 11:25:25 +0000 (+0000) Subject: libs/web: support placeholder attribute for comboboxes, fix validation quirks with... X-Git-Tag: 0.11.0~402 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b35ab62adac0b69630daad0c71e502acbb81b49d;p=oweals%2Fluci.git libs/web: support placeholder attribute for comboboxes, fix validation quirks with input->select transition in comboboxes --- diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js index 655ddbf53..b07215cbc 100644 --- a/libs/web/htdocs/luci-static/resources/cbi.js +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -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) { diff --git a/libs/web/luasrc/view/cbi/value.htm b/libs/web/luasrc/view/cbi/value.htm index 19715a579..d1a7bea5c 100644 --- a/libs/web/luasrc/view/cbi/value.htm +++ b/libs/web/luasrc/view/cbi/value.htm @@ -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-%>