Add NumberInputWidget
for <input type="number" />
This commit is contained in:
parent
a8a4e362a0
commit
046a70c5f6
|
@ -50,6 +50,11 @@ class ReadonlyWidget(dfwidget.HiddenWidget):
|
||||||
return HTML.tag('span', text) + tags.hidden(field.name, value=cstruct, id=field.oid)
|
return HTML.tag('span', text) + tags.hidden(field.name, value=cstruct, id=field.oid)
|
||||||
|
|
||||||
|
|
||||||
|
class NumberInputWidget(dfwidget.TextInputWidget):
|
||||||
|
template = 'numberinput'
|
||||||
|
autocomplete = 'off'
|
||||||
|
|
||||||
|
|
||||||
class PlainSelectWidget(dfwidget.SelectWidget):
|
class PlainSelectWidget(dfwidget.SelectWidget):
|
||||||
template = 'select_plain'
|
template = 'select_plain'
|
||||||
|
|
||||||
|
|
24
tailbone/templates/deform/numberinput.pt
Normal file
24
tailbone/templates/deform/numberinput.pt
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<span tal:define="name name|field.name;
|
||||||
|
css_class css_class|field.widget.css_class;
|
||||||
|
oid oid|field.oid;
|
||||||
|
mask mask|field.widget.mask;
|
||||||
|
mask_placeholder mask_placeholder|field.widget.mask_placeholder;
|
||||||
|
style style|field.widget.style;
|
||||||
|
autocomplete autocomplete|field.widget.autocomplete|'off';
|
||||||
|
"
|
||||||
|
tal:omit-tag="">
|
||||||
|
<input type="number" name="${name}" value="${cstruct}"
|
||||||
|
tal:attributes="class string: form-control ${css_class or ''};
|
||||||
|
style style;
|
||||||
|
autocomplete autocomplete;
|
||||||
|
"
|
||||||
|
id="${oid}"/>
|
||||||
|
<script tal:condition="mask" type="text/javascript">
|
||||||
|
deform.addCallback(
|
||||||
|
'${oid}',
|
||||||
|
function (oid) {
|
||||||
|
$("#" + oid).mask("${mask}",
|
||||||
|
{placeholder:"${mask_placeholder}"});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</span>
|
Loading…
Reference in a new issue