Closed ghost closed 11 years ago
Check that the javascript you need is loaded.
http://docs.pylonsproject.org/projects/deform/en/latest/api.html#deform.widget.DateInputWidget
It requires http://jqueryui.com/demos/datepicker/ .
See also http://docs.pylonsproject.org/projects/deform/en/latest/widget.html#widget-javascript
I have already read this part of the documentation. The HTML markup is really rendered with type="text"
and if in my python code, I add an explicit widget=DateInputWidget()
then it is fine (I have the jQuery ui date picker) and the input in rendered with type="date"
.
Can you tell me if the widget at http://deformdemo.repoze.org/dateinput/ renders incorrectly for you? If so, what browser/version are you using?
Fortunately, the HTML rendering does not seem to depend on the browser. I tested under:
and they all give the same result, which is the following:
<!-- mapping_item -->
<label
class="desc"
title=""
for="deformField1"
>Date<span class="req"
id="req-deformField1">*</span>
</label>
<input type="date"
name="date"
value="2010-05-05"
id="deformField1"/>
<script type="text/javascript">
deform.addCallback(
'deformField1',
function(oid) {
if (!Modernizr.inputtypes['date'] ||
"date" != "date"){
$('#' + oid).datepicker({'dateFormat': 'yy-mm-dd'});
}
}
);
</script>
Here, I can see the type="date"
in the input which looks fine indeed.
Yes, the HTML will be the same, I meant "does it look/work ok".
Under Chromium, I see the date picker from the browser itself. Under Firefox, I see the date picker from jQuery ui. Under Safari, I see the date picker from jQuery ui.
They all look fine. However, concerning my specific problem, it occurs before starting to look at what is rendered by the browsers. Indeed, this is what is received by the browser (an input with type="text"
) that I don't understand.
It sounds like the DateTime widget is behaving as designed. I'm pretty sure I don't understand the actual problem. Can you describe it as if I am a five year old?
In simple words, when I build a schema node like this:
schema.add(colander.SchemaNode(
MySpecificDate(),
description=_('form.marketingseason-update.salesperiod-begin-date-description',
default="Enter the begin date of the sales period with the format dd/mm/yyyy."),
name='begindate',
title=_('form.marketingseason-update.salesperiod-begin-date-label', default="Begin date"),
widget=TextInputWidget()
))
it produces the same as I build the schema node like this:
schema.add(colander.SchemaNode(
MySpecificDate(),
description=_('form.marketingseason-update.salesperiod-begin-date-description',
default="Enter the begin date of the sales period with the format dd/mm/yyyy."),
name='begindate',
title=_('form.marketingseason-update.salesperiod-begin-date-label', default="Begin date")
))
Ok, writing that, I realize my mistake, I am not using colander.Date
but my version of it MySpecificDate
which explains why I don't have the deform.widget.DateInputWidget
as default widget.
Sorry
I have a simple text input generated for a colander.Date field instead of the default deform.widget.DateInputWidget indicated in the documentation : http://docs.pylonsproject.org/projects/deform/en/latest/common_needs.html#changing-the-default-widget-associated-with-a-field